[Numpy-discussion] deprecate numpy.matrix
Matthew Brett
matthew.brett at gmail.com
Mon Feb 10 17:17:58 EST 2014
Hi,
On Mon, Feb 10, 2014 at 2:11 PM, Pauli Virtanen <pav at iki.fi> wrote:
> 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.
That is a very convincing argument.
What would be the problems (apart from code compatibility) in making
scipy.sparse use the ndarray semantics?
Thanks,
Matthew
More information about the NumPy-Discussion
mailing list