2424#include < iostream>
2525
2626#include " eigenpy/eigenpy.hpp"
27+ #include " eigenpy/registration.hpp"
2728#include " eigenpy/exception.hpp"
2829#include " eigenpy/map.hpp"
2930
@@ -190,7 +191,7 @@ namespace eigenpy
190191 typename MapNumpy<EquivalentEigenType>::EigenMap numpyMap = MapNumpy<EquivalentEigenType>::map (pyArray);
191192
192193 void * storage = ((bp::converter::rvalue_from_python_storage<MatType>*)
193- (memory))->storage .bytes ;
194+ (( void *) memory))->storage .bytes ;
194195 assert ( (numpyMap.rows ()<INT_MAX) && (numpyMap.cols ()<INT_MAX)
195196 && " Map range larger than int ... can never happen." );
196197 int r=(int )numpyMap.rows (),c=(int )numpyMap.cols ();
@@ -201,32 +202,16 @@ namespace eigenpy
201202 eigenMatrix = numpyMap;
202203 }
203204 };
204-
205+ #define numpy_import_array () {if (_import_array () < 0 ) {PyErr_Print (); PyErr_SetString (PyExc_ImportError, " numpy.core.multiarray failed to import" ); } }
206+
205207 template <typename MatType,typename EigenEquivalentType>
206208 void enableEigenPySpecific ()
207209 {
208- import_array ();
209-
210- #ifdef EIGEN_DONT_VECTORIZE
211-
212- boost::python::to_python_converter<MatType,
213- eigenpy::EigenToPy<MatType,MatType> >();
214- eigenpy::EigenFromPy<MatType,MatType>();
215- #else
216-
217- boost::python::to_python_converter<MatType,
218- eigenpy::EigenToPy<MatType,MatType> >();
219- eigenpy::EigenFromPy<MatType,MatType>();
210+ if (check_registration<MatType>()) return ;
211+ numpy_import_array ();
220212
221- typedef typename eigenpy::UnalignedEquivalent<MatType>::type MatTypeDontAlign;
222- #ifndef EIGENPY_ALIGNED
223- boost::python::to_python_converter<MatTypeDontAlign,
224- eigenpy::EigenToPy<MatTypeDontAlign,MatTypeDontAlign> >();
225- eigenpy::EigenFromPy<MatTypeDontAlign,MatTypeDontAlign>();
226- #endif
227- #endif
228-
229-
213+ boost::python::to_python_converter<MatType,EigenToPy<MatType,MatType> >();
214+ EigenFromPy<MatType,MatType>();
230215 }
231216
232217} // namespace eigenpy
0 commit comments