Mantid
|
Thin object wrapper around a numpy array. More...
#include <NDArray.h>
Public Member Functions | |
NDArray | astype (char dtype, bool copy=true) const |
Casts (and copies if necessary) the array to the given data type. More... | |
BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS (NDArray, boost::python::object) | |
void * | get_data () const |
This returns char so stride math works properly on it. More... | |
int | get_nd () const |
Py_intptr_t const * | get_shape () const |
char | get_typecode () const |
See https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html. More... | |
NDArray (const boost::python::object &obj) | |
Construction from a plain object. More... | |
Static Public Member Functions | |
static bool | check (const boost::python::object &obj) |
Check if a python object points to an array type object. More... | |
Thin object wrapper around a numpy array.
This is intended to take the place of boost::python::numeric::array, which is a dated wrapper containing a bug when used with Python 3 - https://github.com/boostorg/python/issues/75.
Only minimal functionality has been ported here.
Mantid::PythonInterface::NDArray::NDArray | ( | const boost::python::object & | obj | ) |
Construction from a plain object.
Assumes the array is actually a a numpy array
obj | A wrapper around a Python object pointing to a numpy array |
Definition at line 56 of file NDArray.cpp.
NDArray Mantid::PythonInterface::NDArray::astype | ( | char | dtype, |
bool | copy = true |
||
) | const |
Casts (and copies if necessary) the array to the given data type.
dtype | Character code for the numpy data types (https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html) |
copy | If true then the return array is always a copy otherwise the returned array will only be copied if necessary |
Definition at line 89 of file NDArray.cpp.
References dtype().
Mantid::PythonInterface::NDArray::BOOST_PYTHON_FORWARD_OBJECT_CONSTRUCTORS | ( | NDArray | , |
boost::python::object | |||
) |
|
static |
Check if a python object points to an array type object.
obj | A pointer to an arbitrary python object |
Definition at line 49 of file NDArray.cpp.
References obj.
Referenced by createFunctionDomain1DHistogram(), createFunctionDomain1DVector(), Mantid::PythonInterface::Converters::PyObjectToMatrix::PyObjectToMatrix(), and Mantid::PythonInterface::Registry::SequenceTypeHandler< ContainerType >::set().
void * Mantid::PythonInterface::NDArray::get_data | ( | ) | const |
This returns char so stride math works properly on it.
It's pretty much expected that the user will have to reinterpret_cast it.
Definition at line 73 of file NDArray.cpp.
int Mantid::PythonInterface::NDArray::get_nd | ( | ) | const |
Definition at line 66 of file NDArray.cpp.
Py_intptr_t const * Mantid::PythonInterface::NDArray::get_shape | ( | ) | const |
Definition at line 61 of file NDArray.cpp.
char Mantid::PythonInterface::NDArray::get_typecode | ( | ) | const |
See https://docs.scipy.org/doc/numpy/reference/arrays.dtypes.html.
Definition at line 79 of file NDArray.cpp.