[Numpy-discussion] deprecate numpy.matrix

Matthew Brett matthew.brett at gmail.com
Mon Feb 10 14:36:00 EST 2014


Hi,

On Mon, Feb 10, 2014 at 6:26 AM, Nathaniel Smith <njs at pobox.com> wrote:
> On Sun, Feb 9, 2014 at 4:59 PM, alex <argriffi at ncsu.edu> wrote:
>> Hello list,
>>
>> I wrote this mini-nep for numpy but I've been advised it is more
>> appropriate for discussion on the list.
>>
>> """
>> The ``numpy.matrix`` API provides a low barrier to using Python
>> for linear algebra, just as the pre-3 Python ``input`` function
>> and ``print`` statement provided low barriers to using Python for
>> automatically evaluating input and for printing output.
>>
>> On the other hand, it really needs to be deprecated.
>> Let's deprecate ``numpy.matrix``.
>> """
>>
>> I understand that numpy.matrix will not be deprecated any time soon,
>> but I hope this will register as a vote to help nudge its deprecation
>> closer to the realm of acceptable discussion.
>
> To make this more productive, maybe it would be useful to elaborate on
> what exactly we should do here.
>
> I can't imagine we'll actually remove 'matrix' from the numpy
> namespace at any point in the near future.
{out of order paste}:
> Maybe there should be a big warning to this effect in the np.matrix docstring?

That seems reasonable to me.  Maybe, to avoid heat and fast changes
the NEP could lay out different options with advantages and
disadvantages.

> I do have the sense that when people choose to use it, they eventually
> come to regret this choice. It's a bit buggy and has confusing
> behaviours, and due to limitations of numpy's subclassing model, will
> probably always be buggy and have confusing behaviours. And it's
> marketed as being for new users, who are exactly the kind of users who
> aren't sophisticated enough to recognize these dangers.

This paragraph is a good summary of why the current situation of
np.matrix could cause harm.

It would really useful to have some hard evidence of who's using it
though.  Are there projects that use np.matrix extensively?  If so,
maybe some code from these could be use-cases to see if (pseudo-)
deprecation is practical?

Alex - do you have time to lay this stuff out?  I bet the NEP would be
a good way of helping the discussion stays on track.  At very least it
could be a reference point the next time this comes up.

Thanks for bringing this up,

Matthew



More information about the NumPy-Discussion mailing list