[Numpy-discussion] deprecate numpy.matrix

Matthew Brett matthew.brett at gmail.com
Mon Feb 10 17:54:39 EST 2014


Hi,

On Mon, Feb 10, 2014 at 2:33 PM, Pauli Virtanen <pav at iki.fi> wrote:
> 11.02.2014 00:17, Matthew Brett kirjoitti:
> [clip]
>> That is a very convincing argument.
>>
>> What would be the problems (apart from code compatibility) in making
>> scipy.sparse use the ndarray semantics?
>
> I'd estimate the effort it would take to convert scipy.sparse to ndarray
> semantics is about a couple of afternoon hacks (normal, not
> Ipython-size), so it should be doable.
>
> Also, a shorthand for right-multiplication is probably necessary, as
>
>         A.T.dot(B.T).T
>
> is unwieldy.
>
> As far as backward compatibility goes: change from * to .dot would break
> everyone's code. I suspect the rest of the changes have smaller impacts.
>
> The code breakage is such that I don't think it can be easily done by
> changing the behavior of "csr_matrix". I've previously proposed adding
> csr_array et al., and deprecating csr_matrix et al.. Not sure if the
> *_matrix can ever be removed, but it would be useful to point new users
> to use the interface with the ndarray convention.

Yes, that seems very sensible.

Then what about Chuck's suggestion - np.matrix stays but it is
effectively an independent project that other parts of numpy or scipy
are not required to support.   Scipy.sparse switches to the ndarray
semantics and future subclasses of ndarray should also use ndarray
semantics?

Matthew



More information about the NumPy-Discussion mailing list