[Numpy-discussion] deprecate numpy.matrix
Pauli Virtanen
pav at iki.fi
Mon Feb 10 17:11:55 EST 2014
10.02.2014 23:40, Alan G Isaac kirjoitti:
> On 2/10/2014 4:28 PM, Pauli Virtanen wrote:
>> Starting with asarray won't work: sparse matrices are not
>> subclasses of ndarray.
>
> I was focused on the `matrix` object. For this object, an initial
> asarray is all it takes to use array code. (Or ... not?) And it is
> a view, not a copy.
>
> I don't have the background to know how scipy ended up with a
> sparse matrix object instead of a sparse array object. In any case,
> it seems like a different question.
I think this is very relevant question, and I believe one of the main
motivations for the continuous reappearance of this discussion.
The existence of np.matrix messes up the general agreement on ndarray
semantics in Python. The meaning of very basic code such as
A * B
A.sum(0)
A[0]
where A and B are NxN matrices of some sort now depends on the types
of A and B. This makes writing duck typed code impossible when both
semantics are in play.
This is more of a community and ecosystem question rather than about
np.matrix and asarray().
I think the existence of np.matrix and its influence has set back the
development of a way to express generic linear algebra (dense, sparse,
matrix-free) algorithms in Python.
--
Pauli Virtanen
More information about the NumPy-Discussion
mailing list