[Numpy-discussion] deprecate numpy.matrix
Matthew Brett
matthew.brett at gmail.com
Tue Feb 11 15:35:18 EST 2014
Hi,
On Tue, Feb 11, 2014 at 11:40 AM, Pauli Virtanen <pav at iki.fi> wrote:
> 11.02.2014 21:20, alex kirjoitti:
> [clip]
>> In the spirit of offsetting this bias and because this thread is
>> lacking in examples of projects that use numpy.matrix, here's another
>> data point: cvxpy (https://github.com/cvxgrp/cvxpy) is a serious
>> active project that supports the numpy.matrix interface, for example
>> as in https://github.com/cvxgrp/cvxpy/tree/master/cvxpy/interface/numpy_interface.
>
> Here's some more data:
>
> http://nullege.com/codes/search?cq=numpy.matrix
These are quite revealing. Some of the top hits are from old nipy
code. We don't have any use of np.matrix in the current nipy trunk.
Another couple of hits are from the 'Pylon' package:
https://github.com/rwl/pylon - of this form:
scipy.io.mmwrite("./data/fDC.mtx", numpy.matrix(f_dc))
When I ran the code without the numpy.matrix call it was easy to see
how that happened:
In [4]: scipy.io.mmwrite('fDc.mtx', f_dc)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
...
ValueError: expected matrix
Of course, what the message means is that you should pass a 2D array:
scipy.io.mmwrite('fDc.mtx', f_dc[None])
works fine. So I think this is another example of confusion caused by
np.matrix.
https://github.com/scipy/scipy/pull/3310
Matthew
More information about the NumPy-Discussion
mailing list