Skip to content

Commit ca8d6b6

Browse files
authored
Merge pull request #89 from jmirabel/devel
Add warnings when implicitly using numpy.matrix.
2 parents c6e5497 + 8ea359d commit ca8d6b6

File tree

2 files changed

+13
-1
lines changed

2 files changed

+13
-1
lines changed

.travis.yml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
language: python
22
python:
33
- "2.7"
4+
- "3.5"
45
sudo: required
56
compiler:
67
- gcc

include/eigenpy/details.hpp

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,7 @@ namespace eigenpy
4646

4747
enum NP_TYPE
4848
{
49+
DEFAULT_TYPE,
4950
MATRIX_TYPE,
5051
ARRAY_TYPE
5152
};
@@ -66,6 +67,16 @@ namespace eigenpy
6667

6768
bp::object make(PyObject* pyObj, bool copy = false)
6869
{
70+
if (getType() == DEFAULT_TYPE) {
71+
std::cerr <<
72+
"eigenpy warning: you use the deprecated class numpy.matrix without explicily asking for it. "
73+
"The default behaviour will change to numpy.array at next major release.\n"
74+
"- Either call eigenpy.switchToNumpyMatrix() before using eigenpy to suppress this warning\n"
75+
"- or call eigenpy.switchToNumpyArray() and adapt your code accordingly.\n"
76+
"See https://github.com/stack-of-tasks/eigenpy/issues/87 for further details."
77+
<< std::endl;
78+
switchToNumpyMatrix();
79+
}
6980
bp::object m;
7081
if(PyType_IsSubtype(reinterpret_cast<PyTypeObject*>(CurrentNumpyType.ptr()),NumpyMatrixType))
7182
m = NumpyMatrixObject(bp::object(bp::handle<>(pyObj)), bp::object(), copy);
@@ -122,7 +133,7 @@ namespace eigenpy
122133
//NumpyAsMatrixType = reinterpret_cast<PyTypeObject*>(NumpyAsMatrixObject.ptr());
123134

124135
CurrentNumpyType = NumpyMatrixObject; // default conversion
125-
getType() = MATRIX_TYPE;
136+
getType() = DEFAULT_TYPE;
126137
}
127138

128139
bp::object CurrentNumpyType;

0 commit comments

Comments
 (0)