Types conversion¶
The conversion is done by means of converters module:
from gna.converters import convert
Function convert(object, target_type) converts an object (usually an array) to the target_type.
The following types are recognized:
ROOT.vectoror'stdvector'
ROOT.Pointsor'points'
ROOT.Eigen.MatrixXdor'eigenmatrix'
ROOT.Eigen.VectorXdor'eigenvector'
ROOT.Eigen.ArrayXdor'eigenarray'
ROOT.Eigen.ArrayXXdor'eigenarray2d'
numpy.ndarrayor'array'
numpy.matrixlib.defmatrix.matrixor'matrix'
For more complex conversions see also constructors module.
STD vector¶
|
any numerical std::vector to numpy array (type is guessed) |
|
same as above |
|
same as above with explicit data type (see numpy dtype) |
|
numpy array to std::vector (type is guessed) |
|
same as above |
Eigen¶
|
1d numpy array to Eigen Array (double) |
|
same as above |
|
2d numpy array to Eigen 2D Array (double) |
|
same as above |
|
1d numpy vector (matrix column) to Eigen Vector (double) |
|
same as above |
|
2d numpy array/matrix to Eigen Matrix (double) |
|
same as above |
|
1d Eigen Array to numpy array |
|
2d Eigen Array to numpy array (same as above) |
|
Eigen Matrix to numpy array |
|
Eigen Matrix to numpy matrix |
|
Eigen Vector to numpy matrix |
GNA types¶
|
numpy 1d/2d array to Points |
|
same as above |
Tests¶
Use the following commands for the usage example and testing:
./tests/elementary/test_converters.py