[Numpy-discussion] proposing a "beware of [as]matrix()" warning

Anne Archibald peridot.faceted at gmail.com
Wed Apr 28 17:09:52 EDT 2010


On 28 April 2010 14:30, Alan G Isaac <aisaac at american.edu> wrote:
> On 4/28/2010 12:08 PM, Dag Sverre Seljebotn wrote:
>> it would be good to deprecate the matrix class
>> from NumPy
>
> Please let us not have this discussion all over again.

I think you may be too late on this, but it's worth a try.

> The matrix class is very useful for teaching.
> In economics for example, the use of matrix algebra
> is widespread, while algebra with arrays that are
> not matrices is very rare.  I can (and do) use NumPy
> matrices even in undergraduate courses.
>
> If you do not like them, do not use them.

This is the problem: lots of people start using numpy and think "hmm,
I want to store two-dimensional data so I'll use a matrix", and have
no idea that "matrix" means anything different from "two-dimensional
array". It was this that inspired David's original post, and it's this
that we're trying to find a solution for.

> If you want `matrix` replaced with a better matrix
> object, offer a replacement for community consideration.
>
> Thank you,
> Alan Isaac
>
> PS There is one change I would not mind: let
> A * M be undefined if A is an ndarray and
> M is a NumPy matrix.

I can definitely vote for this, in the interest of catching as many
inadvertent matrix users as possible.

Anne



More information about the NumPy-Discussion mailing list