ChimeraTK-DeviceAccess 03.31.00
Loading...
Searching...
No Matches
PyConvert.h File Reference
#include <ChimeraTK/Exception.h>
#include <ChimeraTK/SupportedUserTypes.h>
#include <pybind11/numpy.h>
+ Include dependency graph for PyConvert.h:

Go to the source code of this file.

Namespaces

namespace  ChimeraTK
 This header collects some conversion routines which should be useful both for ApplicationCore Python bindings and DeviceAccess Python bindings.
 

Functions

template<typename expectedUserType >
expectedUserType ChimeraTK::convertPyScalar (const py::object &input)
 Convert a python scalar (bool, int, float, str; also numpy scalars) into the expected UserType.
 
template<typename expectedUserType , typename FROM >
std::vector< expectedUserType > ChimeraTK::convertTypedPyArray (const py::array &arr)
 helper for 1D numpy array conversion when data types are know at compile time
 
template<typename expectedUserType >
std::vector< expectedUserType > ChimeraTK::convertPyArray (const py::array &arr)
 This takes 1D numpy arrays of any type.
 
template<typename expectedUserType >
std::vector< expectedUserType > ChimeraTK::convertPyList (const py::object &input)
 this takes native python lists, content possibly of mixed types convertToPyArr should be preferred when input is a numpy-array
 
template<typename expectedUserType >
std::vector< expectedUserType > ChimeraTK::convertPyObject (const py::object &input, bool allowScalar, bool allowArray)
 input may be numpy arrays, numpy scalars, python primitives, and lists of numpy scalars or python primitives
 
template<typename expectedUserType , typename FROM >
std::vector< std::vector< expectedUserType > > ChimeraTK::convertTypedPyArray2D (const py::array &arr)
 helper for 2D numpy array conversion when the data type is known at compile time
 
template<typename expectedUserType >
std::vector< std::vector< expectedUserType > > ChimeraTK::convertPyArray2D (const py::array &arr)
 Take a 2D numpy array and convert it into a vector of vectors of expectedUserType (one inner vector per channel).
 
template<typename expectedUserType >
std::vector< std::vector< expectedUserType > > ChimeraTK::convertPyObject2D (const py::object &input)
 input may be a nested python list (list of lists) or a 2D numpy array; result is one inner vector per channel.
 
template<typename expectedUserType >
expectedUserType ChimeraTK::convertScalarValue (const py::object &input)
 Convert a python object (scalar, 1-element list, or 1-element array) into a UserType scalar value.
 
template<typename expectedUserType >
std::optional< expectedUserType > ChimeraTK::convertScalarOptionalValue (const py::object &input)
 Just like convertScalarValue, but input may be empty.