[SciPy-user] change in matrix behavior

Nathan Bell wnbell at gmail.com
Thu May 8 15:12:51 EDT 2008

On Thu, May 8, 2008 at 1:51 PM, Alan G Isaac <aisaac at american.edu> wrote:
> These issues were extensively discussed on the NumPy list.
> I hope you will read that discussion.

I read a substantial part of it.  Really, I think there are only two
positions that make any sense:

1) deprecate numpy.matrix and leave numpy.matrix as-is
2) leave numpy.matrix as-is

Making special matrices for row and column vectors only complicates
matters.  Personally, I favor position 1.

> After *extensive* discussion, most people felt that this is
> a good thing. Among those who did not agree or were not
> sure, raising an error in response to scalar indexing was
> popular.  Otherwise, every function that iterates through
> arrays and expects dimensional reduction as it does so must
> special case matrices.  This was seen as untenable.

This is a case against the existence of matrices, not a case for
changing matrix indexing.  If matrices are to behave like ndarrays
then they don't need to exist.

> Query: How do you use iteration over a matrix?

I was using it here:

Clearly the work around was not difficult, but the change to numpy did
break my code.

> Query: can you specify what needed behavior appears to have
> broken because of this change?

Well, it should do without saying.  Anyone who expected:

1) A[0] to be a 2d matrix
2) A[0] to be of type numpy.matrix
3) iteration over rows to return row matrices

will now have broken code.

I just don't see any argument for making matrices more like arrays
that doesn't logically conclude with eliminating matrices altogether.
The "artifact" of matrices that was recently eliminated was, IMO, one
of the only reasons for them to exist.

Nathan Bell wnbell at gmail.com

More information about the SciPy-User mailing list