[Numpy-discussion] deprecate numpy.matrix

josef.pktd at gmail.com josef.pktd at gmail.com
Mon Feb 10 15:58:06 EST 2014

On Mon, Feb 10, 2014 at 3:45 PM, alex <argriffi at ncsu.edu> wrote:

> On Mon, Feb 10, 2014 at 2:36 PM, Matthew Brett <matthew.brett at gmail.com>
> wrote:
> > 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.
> I don't think I have enough perspective to write a real NEP, but maybe
> as a starting point we could begin a list somewhere, like on a wiki or
> possibly in the numpy github repo, surveying an early 2014 snapshot of
> the linear algebra APIs used by various Python projects.  For example
> according to the responses in this thread, statsmodels seems to avoid
> using numpy.matrix except possibly for interfacing with pandas, and at
> least one professor relies on the numpy.matrix interface for classroom
> teaching.  The list could include short quotes from people involved in
> the projects, if they want to share an opinion.
> It wouldn't be my intention to treat such a list as a vote, but rather
> as data and as an excuse to make a list of cool projects; I suspect
> that members of most projects would say "we don't use numpy.matrix but
> we don't mind if other people use it" and that most teachers or
> students who benefit from the gentler syntax of numpy.matrix would not
> even be reached by such a survey.

My impression:

As long as there is no big maintenance cost (which there isn't), I don't
see any reason to remove matrix and to debate it every few years.
All the users that are participating or reading the mailing list have been
indoctrinated for years not to use matrix.

Alan is one of the only active proponents.

What about the silent hundred thousand users of numpy?  I have no idea what
they are doing.

stage 1 use loops
stage 2 use matrix
stage 3 use arrays

stage 1 and stage 2 is how undergraduate econometrics starts out.

Let's remove loops, users should vectorize.

> Alex
> _______________________________________________
> NumPy-Discussion mailing list
> NumPy-Discussion at scipy.org
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/numpy-discussion/attachments/20140210/c08f5625/attachment.html>

More information about the NumPy-Discussion mailing list