GEOSX
|
Contains all the Python code. More...
Classes | |
class | PyObjectRef |
A class that manages an owned Python reference with RAII semantics. More... | |
class | PythonError |
Base class for all C++ exceptions related to Python. More... | |
class | PythonFunction |
A C++ functor wrapper around a Python function. More... | |
Enumerations | |
enum | PyModify { READ_ONLY = 0, MODIFIABLE = 1, RESIZEABLE = 2 } |
An enumeration of the various access policies for Python objects. | |
Functions | |
bool | import_array_wrapper () |
Attempt to import the NumPy API if it was not already imported, return true iff successful. More... | |
template<typename T , typename INDEX_TYPE > | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | createNumPyArray (T *const data, bool const modify, int const ndim, INDEX_TYPE const *const dimsPtr, INDEX_TYPE const *const stridesPtr) |
Return a NumPy ndarray view of data . More... | |
template<typename T > | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | create (T &value) |
Create a NumPy 1D array of length 1 containing the scalar value . More... | |
std::tuple< PyObjectRef< PyObject >, void const *, long long > | parseNumPyArray (PyObject *const obj, std::type_index const expectedType) |
Attempt to parse obj into a NumPy ndarray of type expectedType . More... | |
std::type_index | getTypeIndexFromNumPy (int const numpyType) |
Return the std::type_index corresponding to the NumPy type numpyType . More... | |
std::string | getNumPyTypeName (int const numpyType) |
Return the name corresponding to the NumPy type numpyType . More... | |
PyObject * | getNumPyTypeObject (std::type_index const typeIndex) |
Return the NumPy type object corresponding to typeIndex . More... | |
template<typename T , int NDIM, typename PERM , typename INDEX_TYPE , template< typename > class BUFFER_TYPE> | |
std::enable_if_t< internal::canExportToNumpy< T >||(std::is_same< T, std::string >::value &&NDIM==1), PyObject *> | create (Array< T, NDIM, PERM, INDEX_TYPE, BUFFER_TYPE > &array) |
Create a Python object corresponding to array . More... | |
PyTypeObject * | getPyArrayType () |
Return the Python type for the Array. More... | |
template<typename T , typename INDEX_TYPE , template< typename > class BUFFER_TYPE> | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | create (ArrayOfArrays< T, INDEX_TYPE, BUFFER_TYPE > &arrayOfArrays) |
Create a Python object corresponding to arrayOfArrays . More... | |
PyTypeObject * | getPyArrayOfArraysType () |
Return the Python type object for the ArrayOfArrays. More... | |
template<typename T , typename INDEX_TYPE , template< typename > class BUFFER_TYPE> | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | create (ArrayOfSets< T, INDEX_TYPE, BUFFER_TYPE > &arrayOfSets) |
Create a Python object corresponding to arrayOfSets . More... | |
PyTypeObject * | getPyArrayOfSetsType () |
Return the Python type for the ArrayOfSets. More... | |
template<typename T , typename COL_TYPE , typename INDEX_TYPE , template< typename > class BUFFER_TYPE> | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | create (CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > &matrix) |
Create a Python object corresponding to matrix . More... | |
PyTypeObject * | getPyCRSMatrixType () |
Return the Python type for the CRSMatrix. More... | |
template<typename T , typename INDEX_TYPE , template< typename > class BUFFER_TYPE> | |
std::enable_if_t< internal::canExportToNumpy< T >, PyObject *> | create (SortedArray< T, INDEX_TYPE, BUFFER_TYPE > &sortedArray) |
Create a Python object corresponding to sortedArray . More... | |
PyTypeObject * | getPySortedArrayType () |
Return the Python type for the SortedArray. More... | |
bool | addPyLvArrayModule (PyObject *module) |
add the pylvarray module, which defines all of the pylvarray classes, to a module. More... | |
IS_VALID_EXPRESSION (CanCreate, T, LvArray::python::create(std::declval< T & >())) | |
Expands to a static constexpr template bool. More... | |
template<typename T > | |
T * | convert (PyObject *const obj, PyTypeObject *const type) |
Return obj casted to T if obj is an instance of type or nullptr if it is not. More... | |
bool | addTypeToModule (PyObject *const module, PyTypeObject *const type, char const *const typeName) |
Add the Python type type to the module module . More... | |
PyObject * | create (std::string const &value) |
Return a Python string copy of value . More... | |
PyObject * | createPyListOfStrings (std::string const *const strptr, long long const size) |
Create and return a Python list of strings from an array of std::strings. The Python strings will be copies. More... | |
PyObject * | create (std::vector< std::string > const &vec) |
Create and return a Python list of strings from a std::vector of std::strings. The Python strings will be copies. More... | |
Contains all the Python code.
bool LvArray::python::addPyLvArrayModule | ( | PyObject * | module | ) |
add the pylvarray
module, which defines all of the pylvarray
classes, to a module.
module | the Python module object to add pylvarray to as the attribute named "pylvarray". Equivalent to import pylvarray; module.pylvarray = pylvarray . |
bool LvArray::python::addTypeToModule | ( | PyObject *const | module, |
PyTypeObject *const | type, | ||
char const *const | typeName | ||
) |
Add the Python type type
to the module module
.
module | The Python module to add type to. |
type | The Python type to add to module . |
typeName | The name to give the type. |
true
iff the operation was successful. T* LvArray::python::convert | ( | PyObject *const | obj, |
PyTypeObject *const | type | ||
) |
Return obj
casted to T if obj
is an instance of type
or nullptr
if it is not.
T | The type to cast obj to. |
obj | The object. |
type | The type. |
obj
casted to T if obj
is an instance of type
or nullptr
if it is not. Definition at line 272 of file pythonHelpers.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::create | ( | T & | value | ) |
Create a NumPy 1D array of length 1 containing the scalar value
.
T | The type of the scalar value , if const then the returned array is immutable. |
value | The type to export. |
Definition at line 147 of file numpyHelpers.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::create | ( | SortedArray< T, INDEX_TYPE, BUFFER_TYPE > & | sortedArray | ) |
Create a Python object corresponding to sortedArray
.
T | The type of values in the SortedArray. |
INDEX_TYPE | The index type of the SortedArray. |
BUFFER_TYPE | The buffer type of the SortedArray. |
sortedArray | The SortedArray to export to Python. |
sortedArray
. sortedArray
, you must ensure the reference remains valid throughout the lifetime of the object. Definition at line 216 of file PySortedArray.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::create | ( | ArrayOfSets< T, INDEX_TYPE, BUFFER_TYPE > & | arrayOfSets | ) |
Create a Python object corresponding to arrayOfSets
.
T | The type of the entries in the ArrayOfSets. |
INDEX_TYPE | The index type of the ArrayOfSets. |
BUFFER_TYPE | The buffer type of the ArrayOfSets. |
arrayOfSets | The ArrayOfSets to export to Python. |
arrayOfSets
. arrayOfSets
, you must ensure the reference remains valid throughout the lifetime of the object. Definition at line 271 of file PyArrayOfSets.hpp.
std::enable_if_t< internal::canExportToNumpy< T > || ( std::is_same< T, std::string >::value && NDIM == 1 ), PyObject * > LvArray::python::create | ( | Array< T, NDIM, PERM, INDEX_TYPE, BUFFER_TYPE > & | array | ) |
Create a Python object corresponding to array
.
T | The type of values in the array. |
NDIM | The dimensionality of the array. |
PERM | The permutation of the array. |
INDEX_TYPE | The index type of the array. |
BUFFER_TYPE | The buffer type of the array. |
array | The Array to export to Python. |
array
. array
, you must ensure the reference remains valid throughout the lifetime of the object. Definition at line 279 of file PyArray.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::create | ( | ArrayOfArrays< T, INDEX_TYPE, BUFFER_TYPE > & | arrayOfArrays | ) |
Create a Python object corresponding to arrayOfArrays
.
T | The type of the entries in the ArrayOfArrays. |
INDEX_TYPE | The index type of the ArrayOfArrays. |
BUFFER_TYPE | The buffer type of the ArrayOfArrays. |
arrayOfArrays | The ArrayOfArrays to export to Python. |
arrayOfArrays
. arrayOfArrays
, you must ensure the reference remains valid throughout the lifetime of the object. Definition at line 287 of file PyArrayOfArrays.hpp.
PyObject* LvArray::python::create | ( | std::string const & | value | ) |
Return a Python string copy of value
.
value | The string to copy into Python. |
value
.
|
inline |
Create and return a Python list of strings from a std::vector of std::strings. The Python strings will be copies.
vec | the vector to convert. |
nullptr
if there was an error. Definition at line 315 of file pythonHelpers.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::create | ( | CRSMatrix< T, COL_TYPE, INDEX_TYPE, BUFFER_TYPE > & | matrix | ) |
Create a Python object corresponding to matrix
.
T | The type of the entries in the CRSMatrix. |
COL_TYPE | The type of the columns in the CRSMatrix. |
INDEX_TYPE | The index type of the CRSMatrix. |
BUFFER_TYPE | The buffer type of the CRSMatrix. |
matrix | The CRSMatrix to export to Python. |
matrix
. matrix
, you must ensure the reference remains valid throughout the lifetime of the object. Definition at line 408 of file PyCRSMatrix.hpp.
std::enable_if_t< internal::canExportToNumpy< T >, PyObject * > LvArray::python::createNumPyArray | ( | T *const | data, |
bool const | modify, | ||
int const | ndim, | ||
INDEX_TYPE const *const | dimsPtr, | ||
INDEX_TYPE const *const | stridesPtr | ||
) |
Return a NumPy ndarray view of data
.
T | The type of values in the array. |
INDEX_TYPE | The index type of the array. |
data | A pointer to the data to export. |
modify | If the ndarray should have modifiable values, only has an effect iff |
T | is not const . |
ndim | The number of dimensions of data . |
dimsPtr | The size of each dimension. |
stridesPtr | The strides of each dimension. |
data
. Definition at line 107 of file numpyHelpers.hpp.
PyObject* LvArray::python::createPyListOfStrings | ( | std::string const *const | strptr, |
long long const | size | ||
) |
Create and return a Python list of strings from an array of std::strings. The Python strings will be copies.
strptr | A pointer to the strings to convert, must be of length size . |
size | The number of strings in strptr . |
nullptr
if there was an error. std::string LvArray::python::getNumPyTypeName | ( | int const | numpyType | ) |
Return the name corresponding to the NumPy type numpyType
.
numpyType | The NumPy type to convert. |
numpyType
. PyObject* LvArray::python::getNumPyTypeObject | ( | std::type_index const | typeIndex | ) |
Return the NumPy type object corresponding to typeIndex
.
typeIndex | The type to convert to a NumPy type. |
typeIndex
. If an error occurs a Python exception is set and a nullptr
is returned. PyTypeObject* LvArray::python::getPyArrayOfArraysType | ( | ) |
Return the Python type object for the ArrayOfArrays.
PyTypeObject* LvArray::python::getPyArrayOfSetsType | ( | ) |
Return the Python type for the ArrayOfSets.
PyTypeObject* LvArray::python::getPyArrayType | ( | ) |
PyTypeObject* LvArray::python::getPyCRSMatrixType | ( | ) |
PyTypeObject* LvArray::python::getPySortedArrayType | ( | ) |
Return the Python type for the SortedArray.
std::type_index LvArray::python::getTypeIndexFromNumPy | ( | int const | numpyType | ) |
Return the std::type_index
corresponding to the NumPy type numpyType
.
numpyType | The NumPy type to convert. |
std::type_index
corresponding to the NumPy type numpyType
. bool LvArray::python::import_array_wrapper | ( | ) |
Attempt to import the NumPy API if it was not already imported, return true
iff successful.
true
iff the NumPy API was successfully imported. LvArray::python::IS_VALID_EXPRESSION | ( | CanCreate | , |
T | , | ||
LvArray::python::create(std::declval< T &>()) | |||
) |
Expands to a static constexpr template bool.
which is true iff T
is a type which LvArray can export to Python.
std::tuple< PyObjectRef< PyObject >, void const *, long long > LvArray::python::parseNumPyArray | ( | PyObject *const | obj, |
std::type_index const | expectedType | ||
) |
Attempt to parse obj
into a NumPy ndarray of type expectedType
.
obj | The object to parse. |
expectedType | The expected type of the values in the ndarray. |