Mantid
Loading...
Searching...
No Matches
Public Types | Public Member Functions | Private Member Functions | Private Attributes | List of all members
Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType > Struct Template Reference

Converter taking an input numpy array and converting it to a std::vector. More...

#include <NDArrayToVector.h>

Public Types

using TypedVector = std::vector< DestElementType >
 
using TypedVectorIterator = typename std::vector< DestElementType >::iterator
 

Public Member Functions

void copyTo (TypedVector &dest) const
 Fill the container with data from the array. More...
 
 NDArrayToVector (const NDArray &value)
 Constructor. More...
 
TypedVector operator() ()
 Create a new vector from the contents of the array. More...
 

Private Member Functions

void throwIfSizeMismatched (const TypedVector &dest) const
 

Private Attributes

NDArray m_arr
 

Detailed Description

template<typename DestElementType>
struct Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >

Converter taking an input numpy array and converting it to a std::vector.

Multi-dimensional arrays are flattened and copied.

Definition at line 20 of file NDArrayToVector.h.

Member Typedef Documentation

◆ TypedVector

template<typename DestElementType >
using Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::TypedVector = std::vector<DestElementType>

Definition at line 22 of file NDArrayToVector.h.

◆ TypedVectorIterator

template<typename DestElementType >
using Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::TypedVectorIterator = typename std::vector<DestElementType>::iterator

Definition at line 23 of file NDArrayToVector.h.

Constructor & Destructor Documentation

◆ NDArrayToVector()

template<typename DestElementType >
Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::NDArrayToVector ( const NDArray value)

Constructor.

Parameters
value:: A boost python object wrapping a numpy.ndarray

Definition at line 117 of file NDArrayToVector.cpp.

Member Function Documentation

◆ copyTo()

template<typename DestElementType >
void Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::copyTo ( TypedVector dest) const

Fill the container with data from the array.

Parameters
destA pre-sized container that will receive the values from the array. It's size is checked against the array size.

Definition at line 136 of file NDArrayToVector.cpp.

◆ operator()()

template<typename DestElementType >
NDArrayToVector< DestElementType >::TypedVector Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::operator()

Create a new vector from the contents of the array.

Creates a vector of the DestElementType from the numpy array of given input type.

Returns
A vector of the DestElementType created from the numpy array

Definition at line 125 of file NDArrayToVector.cpp.

◆ throwIfSizeMismatched()

template<typename DestElementType >
void Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::throwIfSizeMismatched ( const TypedVector dest) const
private
Parameters
destA reference to a vector whose capacity is checked that it can contain the values from the numpy array
Exceptions
std::invalid_argumentif the vector is the wrong size or the numpy array is not 1D

Definition at line 150 of file NDArrayToVector.cpp.

References std::to_string().

Member Data Documentation

◆ m_arr

template<typename DestElementType >
NDArray Mantid::PythonInterface::Converters::NDArrayToVector< DestElementType >::m_arr
private

Definition at line 36 of file NDArrayToVector.h.


The documentation for this struct was generated from the following files: