[Numpy-discussion] Release of NumPy

Alan G Isaac aisaac@american....
Wed Apr 16 09:06:05 CDT 2008

On Wed, 16 Apr 2008, Anne Archibald apparently wrote:
> My (draconian) suggestion would be to simply raise an 
> exception when a matrix is indexed with a scalar.

This has been suggested before.  But then, why?
Again, this imposes a deviation from the behavior of
arrays that provides no gain in functionality.
My proposal is: deviate from array behavior only when
it gives a clear gain in functionality.

> They're inherently two-dimensional;

Of course.  But the question is what follows from this
as an implication for the behavior of 1d indexing and
iteration.  The answer is: nothing!
We get to do whatever is most useful!

> if you want a submatrix you should provide both indices 
> (possibly including a ":").

Yes.  We exactly agree on this.
Please persuade Stefan.

> If you actually want a subarray, as with an array, use 
> ".A".

Again we agree on this.

But none of this answers the question:
what should you get when you iterate over a matrix.
Stefan seems to agree with me to this extent:
we should get its "rows".  This disagreement is
over what that means:
are these submatrices, a new vector object, or 1d arrays?
I claim that if you use matrices, you will find it
natural for these to be 1d arrays.

> That said, I don't actually use matrices, so I don't get a vote. 

As far as I know, no objections have been raised by users of 
matrices.  In this sense, the objections have all been "abstract":
they do not reflect experience with the implied convenience 
or inconvenience or particular behaviors.

Alan Isaac

More information about the Numpy-discussion mailing list