@@ -79,18 +79,18 @@ namespace eigenpy
7979 return instance;
8080 }
8181
82- operator bp::object () { return CurrentNumpyType; }
82+ operator bp::object () { return getInstance (). CurrentNumpyType ; }
8383
84- bp::object make (PyArrayObject* pyArray, bool copy = false )
84+ static bp::object make (PyArrayObject* pyArray, bool copy = false )
8585 { return make ((PyObject*)pyArray,copy); }
8686
87- bp::object make (PyObject* pyObj, bool copy = false )
87+ static bp::object make (PyObject* pyObj, bool copy = false )
8888 {
8989 bp::object m;
90- if (PyType_IsSubtype ( reinterpret_cast <PyTypeObject*>(CurrentNumpyType. ptr ()),NumpyMatrixType ))
91- m = NumpyMatrixObject (bp::object (bp::handle<>(pyObj)), bp::object (), copy);
90+ if (isMatrix ( ))
91+ m = getInstance (). NumpyMatrixObject (bp::object (bp::handle<>(pyObj)), bp::object (), copy);
9292// m = NumpyAsMatrixObject(bp::object(bp::handle<>(pyObj)));
93- else if (PyType_IsSubtype ( reinterpret_cast <PyTypeObject*>(CurrentNumpyType. ptr ()),NumpyArrayType ))
93+ else if (isArray ( ))
9494 m = bp::object (bp::handle<>(pyObj)); // nothing to do here
9595
9696 Py_INCREF (m.ptr ());
@@ -109,19 +109,18 @@ namespace eigenpy
109109 static void switchToNumpyArray ()
110110 {
111111 getInstance ().CurrentNumpyType = getInstance ().NumpyArrayObject ;
112- getType () = ARRAY_TYPE;
112+ getInstance (). getType () = ARRAY_TYPE;
113113 }
114114
115115 static void switchToNumpyMatrix ()
116116 {
117117 getInstance ().CurrentNumpyType = getInstance ().NumpyMatrixObject ;
118- getType () = MATRIX_TYPE;
118+ getInstance (). getType () = MATRIX_TYPE;
119119 }
120120
121121 static NP_TYPE & getType ()
122122 {
123- static NP_TYPE np_type;
124- return np_type;
123+ return getInstance ().np_type ;
125124 }
126125
127126 static bp::object getNumpyType ()
@@ -147,6 +146,7 @@ namespace eigenpy
147146
148147 static bool isArray ()
149148 {
149+ if (getInstance ().isMatrix ()) return false ;
150150 return PyType_IsSubtype (reinterpret_cast <PyTypeObject*>(getInstance ().CurrentNumpyType .ptr ()),
151151 getInstance ().NumpyArrayType );
152152 }
@@ -169,7 +169,7 @@ namespace eigenpy
169169 // NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());
170170
171171 CurrentNumpyType = NumpyArrayObject; // default conversion
172- getType () = ARRAY_TYPE;
172+ np_type = ARRAY_TYPE;
173173 }
174174
175175 bp::object CurrentNumpyType;
@@ -179,7 +179,8 @@ namespace eigenpy
179179 bp::object NumpyMatrixObject; PyTypeObject * NumpyMatrixType;
180180 // bp::object NumpyAsMatrixObject; PyTypeObject * NumpyAsMatrixType;
181181 bp::object NumpyArrayObject; PyTypeObject * NumpyArrayType;
182-
182+
183+ NP_TYPE np_type;
183184 };
184185
185186 template <typename MatType, bool IsVectorAtCompileTime = MatType::IsVectorAtCompileTime>
0 commit comments