[Numpy-discussion] deprecate numpy.matrix
njs at pobox.com
Mon Feb 10 09:26:59 EST 2014
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.
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.
Maybe there should be a big warning to this effect in the np.matrix docstring?
Maybe using np.matrix should raise a DeprecationWarning?
(DeprecationWarning doesn't have to mean that something will be
disappearing -- e.g. the Python stdlib deprecates stuff all the time,
but never actually removes it. It's just a warning flag that there are
better options available.)
Nathaniel J. Smith
Postdoctoral researcher - Informatics - University of Edinburgh
More information about the NumPy-Discussion