[Numpy-discussion] deprecate numpy.matrix

Jacco Hoekstra - LR J.M.Hoekstra at tudelft.nl
Tue Feb 11 07:16:09 EST 2014

For our students, the matrix class is really appealing as we use a lot of linear algebra and expressions with matrices simply look better with an operator instead of a function:


looks much better than 

	x = np.dot(np.linalg.inv(A),b) 

And this gets worse when the expression is longer:

	x = R.I*A*R*b 


	x = np.dot( np.linalg.inv(R), np.dot(A, np.dot(R, b)))

Actually, not being involved in earlier discussions on this topic, I was a bit surprised by this and do not see the problem of having the matrix class as nobody is obliged to use it. I tried to find the reasons, but did not find it in the thread mentioned. Maybe someone could summarize the main problem with keeping this class for newbies on this list like me?

Anyway, I would say that there is a clear use for the matrix class: readability of linear algebra code and hence a lower chance of errors, so higher productivity.  

Just my 2cts,
    Jacco Hoekstra

P.S. Also:   A = np.mat("2 3 ; -1 0") is very handy!

-----Original Message-----
From: numpy-discussion-bounces at scipy.org [mailto:numpy-discussion-bounces at scipy.org] On Behalf Of Pauli Virtanen
Sent: dinsdag 11 februari 2014 12:47
To: numpy-discussion at scipy.org
Subject: Re: [Numpy-discussion] deprecate numpy.matrix

Sturla Molden <sturla.molden <at> gmail.com> writes:
> Pauli Virtanen <pav <at> iki.fi> wrote:
> > It is not a good thing that there is no well defined "domain 
> > specific language" for matrix algebra in Python.
> Perhaps Python should get some new operators?

It might still be possible to advocate for this in core Python, even though the ship has sailed long ago.

Some previous discussion:

[1] http://fperez.org/py4science/numpy-pep225/numpy-pep225.html
[2] http://www.python.org/dev/peps/pep-0225/
[3] http://www.python.org/dev/peps/pep-0211/

(My own take would be that one extra operator is enough for most purposes, and would be easier to push for.)

> On the serious side, I don't think there really is a good solution to 
> this problem at all.

This is true. However, I'd prefer to have one solution over several conflicting ones.

Pauli Virtanen

NumPy-Discussion mailing list
NumPy-Discussion at scipy.org

More information about the NumPy-Discussion mailing list