@@ -275,13 +275,13 @@ namespace eigenpy
275275 memory->convertible = storage->storage .bytes ;
276276 }
277277
278- template <typename MatType>
278+ template <typename MatType, typename _Scalar >
279279 struct EigenFromPy
280280 {
281281 typedef typename MatType::Scalar Scalar;
282282
283283 // / \brief Determine if pyObj can be converted into a MatType object
284- static void * convertible (PyArrayObject* pyArray );
284+ static void * convertible (PyObject* pyObj );
285285
286286 // / \brief Allocate memory and copy pyObj in the new storage
287287 static void construct (PyObject* pyObj,
@@ -290,12 +290,14 @@ namespace eigenpy
290290 static void registration ();
291291 };
292292
293- template <typename MatType>
294- void * EigenFromPy<MatType>::convertible(PyArrayObject* pyArray )
293+ template <typename MatType, typename _Scalar >
294+ void * EigenFromPy<MatType,_Scalar >::convertible(PyObject* pyObj )
295295 {
296- if (!call_PyArray_Check (reinterpret_cast <PyObject*>(pyArray )))
296+ if (!call_PyArray_Check (reinterpret_cast <PyObject*>(pyObj )))
297297 return 0 ;
298298
299+ PyArrayObject * pyArray = reinterpret_cast <PyArrayObject*>(pyObj);
300+
299301 if (!np_type_is_convertible_into_scalar<Scalar>(EIGENPY_GET_PY_ARRAY_TYPE (pyArray)))
300302 return 0 ;
301303
@@ -403,15 +405,15 @@ namespace eigenpy
403405 return pyArray;
404406 }
405407
406- template <typename MatType>
407- void EigenFromPy<MatType>::construct(PyObject* pyObj,
408- bp::converter::rvalue_from_python_stage1_data* memory)
408+ template <typename MatType, typename _Scalar >
409+ void EigenFromPy<MatType,_Scalar >::construct(PyObject* pyObj,
410+ bp::converter::rvalue_from_python_stage1_data* memory)
409411 {
410412 eigen_from_py_construct<MatType>(pyObj,memory);
411413 }
412414
413- template <typename MatType>
414- void EigenFromPy<MatType>::registration()
415+ template <typename MatType, typename _Scalar >
416+ void EigenFromPy<MatType,_Scalar >::registration()
415417 {
416418 bp::converter::registry::push_back
417419 (reinterpret_cast <void *(*)(_object *)>(&EigenFromPy::convertible),
@@ -431,7 +433,7 @@ namespace eigenpy
431433
432434 // Add conversion to Eigen::EigenBase<MatType>
433435 typedef Eigen::EigenBase<MatType> EigenBase;
434- EigenFromPy<EigenBase>::registration ();
436+ EigenFromPy<EigenBase, typename MatType::Scalar >::registration ();
435437
436438 // Add conversion to Eigen::PlainObjectBase<MatType>
437439 typedef Eigen::PlainObjectBase<MatType> PlainObjectBase;
@@ -449,8 +451,8 @@ namespace eigenpy
449451 }
450452 };
451453
452- template <typename MatType>
453- struct EigenFromPy < Eigen::MatrixBase<MatType> > : EigenFromPy<MatType>
454+ template <typename MatType, typename _Scalar >
455+ struct EigenFromPy < Eigen::MatrixBase<MatType>, _Scalar > : EigenFromPy<MatType>
454456 {
455457 typedef EigenFromPy<MatType> EigenFromPyDerived;
456458 typedef Eigen::MatrixBase<MatType> Base;
@@ -463,8 +465,8 @@ namespace eigenpy
463465 }
464466 };
465467
466- template <typename MatType>
467- struct EigenFromPy < Eigen::EigenBase<MatType> > : EigenFromPy<MatType>
468+ template <typename MatType, typename _Scalar >
469+ struct EigenFromPy < Eigen::EigenBase<MatType>, _Scalar > : EigenFromPy<MatType>
468470 {
469471 typedef EigenFromPy<MatType> EigenFromPyDerived;
470472 typedef Eigen::EigenBase<MatType> Base;
@@ -477,8 +479,8 @@ namespace eigenpy
477479 }
478480 };
479481
480- template <typename MatType>
481- struct EigenFromPy < Eigen::PlainObjectBase<MatType> > : EigenFromPy<MatType>
482+ template <typename MatType, typename _Scalar >
483+ struct EigenFromPy < Eigen::PlainObjectBase<MatType>, _Scalar > : EigenFromPy<MatType>
482484 {
483485 typedef EigenFromPy<MatType> EigenFromPyDerived;
484486 typedef Eigen::PlainObjectBase<MatType> Base;
@@ -493,20 +495,21 @@ namespace eigenpy
493495
494496#if EIGEN_VERSION_AT_LEAST(3,2,0)
495497
496- template <typename MatType, int Options, typename Stride>
497- struct EigenFromPy <Eigen::Ref<MatType,Options,Stride> >
498+ template <typename MatType, int Options, typename Stride, typename _Scalar >
499+ struct EigenFromPy <Eigen::Ref<MatType,Options,Stride>,_Scalar >
498500 {
499501 typedef Eigen::Ref<MatType,Options,Stride> RefType;
500502 typedef typename MatType::Scalar Scalar;
501503
502504 // / \brief Determine if pyObj can be converted into a MatType object
503- static void * convertible (PyArrayObject * pyArray )
505+ static void * convertible (PyObject * pyObj )
504506 {
505- if (!call_PyArray_Check (reinterpret_cast <PyObject*>(pyArray) ))
507+ if (!call_PyArray_Check (pyObj ))
506508 return 0 ;
509+ PyArrayObject * pyArray = reinterpret_cast <PyArrayObject*>(pyObj);
507510 if (!PyArray_ISWRITEABLE (pyArray))
508511 return 0 ;
509- return EigenFromPy<MatType>::convertible (pyArray );
512+ return EigenFromPy<MatType>::convertible (pyObj );
510513 }
511514
512515 static void registration ()
@@ -517,16 +520,16 @@ namespace eigenpy
517520 }
518521 };
519522
520- template <typename MatType, int Options, typename Stride>
521- struct EigenFromPy <const Eigen::Ref<const MatType,Options,Stride> >
523+ template <typename MatType, int Options, typename Stride, typename _Scalar >
524+ struct EigenFromPy <const Eigen::Ref<const MatType,Options,Stride>,_Scalar >
522525 {
523526 typedef const Eigen::Ref<const MatType,Options,Stride> ConstRefType;
524527 typedef typename MatType::Scalar Scalar;
525528
526529 // / \brief Determine if pyObj can be converted into a MatType object
527- static void * convertible (PyArrayObject * pyArray )
530+ static void * convertible (PyObject * pyObj )
528531 {
529- return EigenFromPy<MatType>::convertible (pyArray );
532+ return EigenFromPy<MatType>::convertible (pyObj );
530533 }
531534
532535 static void registration ()
0 commit comments