[Numpy-discussion] untenable matrix behavior in SVN

Alan G Isaac aisaac at american.edu
Fri Apr 25 14:02:02 EDT 2008


On Fri, 25 Apr 2008, Stéfan van der Walt apparently wrote:
> Reverted in r5084. 

Thank you.

I think we have discovered that there is a basic conflict 
between two behaviors:

        x[0] == x[0,:]
        vs.
        x[0][0] == x[0,0]

To my recollection, everyone has agree that the second 
behavior is desirable as a *basic expectation* about the
behavior of 2d objects.  This implies that *eventually* we 
will have ``x[0][0] == x[0,0]``.  But then eventually
we MUST eventually have x[0] != x[0,:].

Since a current behavior must disappear eventually, we 
should make it disappear as soon as possible: before the 
release.  The question is how.  I see two simple ways to 
move forward immediately:

        1. scalar indexing of matrices returns a 1d array
        2. scalar indexing of matrices raises a TypeError

If we raise a TypeError, we lose both behaviors.
If we return a 1d array, we retain the behavior
that has been seen as desirable (as a *basic expectation* 
about the behavior of 2d objects).

Stefan, do you agree, and if so, would you be willing to 
have a vote on these two options?

Alan






More information about the NumPy-Discussion mailing list