18 #ifdef BORNAGAIN_PYTHON
24 std::vector<size_t> dimensions;
25 for (
size_t i = 0; i <
getRank(); i++)
29 if (dimensions.size() == 2)
33 npy_int ndim_numpy = (int)dimensions.size();
34 npy_intp* ndimsizes_numpy =
new npy_intp[dimensions.size()];
35 for (
size_t i = 0; i < dimensions.size(); i++)
36 ndimsizes_numpy[i] = dimensions[i];
39 PyObject* pyarray = PyArray_SimpleNew(ndim_numpy, ndimsizes_numpy, NPY_DOUBLE);
40 delete[] ndimsizes_numpy;
41 if (pyarray ==
nullptr)
45 double* array_buffer = (
double*)PyArray_DATA((PyArrayObject*)pyarray);
54 array_buffer[offset] = (*this)[index];
59 *array_buffer++ = (*
this)[index];
69 return (*
this)[index];
74 return (*
this)[index].getContent();
Defines class CumulativeValue.
void swap(OutputDataIterator< TValue, TContainer > &left, OutputDataIterator< TValue, TContainer > &right)
make Swappable
Defines and implements template class OutputData.
Includes python header and takes care of warnings.
virtual size_t size() const =0
retrieve the number of bins
double getValue(size_t index) const
Returns value or summed value, depending on T.
std::vector< int > getAxesBinIndices(size_t global_index) const
Returns vector of axes indices for given global index.
size_t getRank() const
Returns number of dimensions.
const IAxis & getAxis(size_t serial_number) const
returns axis with given serial number
SafePointerVector< IAxis > m_value_axes
size_t getAllocatedSize() const
Returns total size of data buffer (product of bin number in every dimension).
PyObject * getArray() const
returns data as Python numpy array