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.vector
or'stdvector'
ROOT.Points
or'points'
ROOT.Eigen.MatrixXd
or'eigenmatrix'
ROOT.Eigen.VectorXd
or'eigenvector'
ROOT.Eigen.ArrayXd
or'eigenarray'
ROOT.Eigen.ArrayXXd
or'eigenarray2d'
numpy.ndarray
or'array'
numpy.matrixlib.defmatrix.matrix
or'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