[Numpy-discussion] numpy release

Stéfan van der Walt stefan@sun.ac...
Fri Apr 25 12:27:41 CDT 2008

2008/4/25 Anne Archibald <peridot.faceted@gmail.com>:
>  > The agreement was:

Clearly that was only the agreement in my mind.  I apologise if I
jumped the gun.

>  >  a) That x[0][0] should be equal to x[0,0] and
>  >  b) That x[0,:] should be equal to x[0] (as for ndarrays)
>  >
>  >  This breaks as little functionality as possible, at the cost of one
>  >  (instead of two) API changes.
>  Hold on. There has definitely been some confusion here. This is not
>  what I thought I was suggesting, or what Alan thought he was
>  suggesting. I do not think special-casing matrices for which one
>  dimension happens to be one is a good idea at all, even temporarily.
>  This is the kind of thing that drives users crazy.

Apparently, not having x[0][0] == x[0,0] drives them even crazier :)
I was trying to satisfy Alan's request without breaking the API in
more than one place.  The whole idea of matrices was that you always
work with 2-dimensional arrays, even when you just extract a row.
Unless you have a proper hierarchical container (as illustrated in the
other patch I sent), returning a 1D array breaks at least some
expectation.  If that's what the matrix users want, though, then we
should change it.

>  My suggested stopgap fix was to make x[0] return a 1D *array*; I feel
>  that this will result in less special-casing. In fact I wasn't aware
>  that anyone had proposed the fix you implemented. Can we change the
>  stopgap solution?

Yes, of course.  NumPy is a community project, after all.

>  >  We should now discuss the proposals on the table, choose a good one,
>  >  and implement all the API changes necessary for 1.2 or 2.  It's a pity
>  >  we have to change the API again, but the current situation is not
>  >  tenable.
>  Yes, well, it really looks unlikely we will be able to agree on what
>  the correct solution is before 1.1, so I would like to have something
>  non-broken for that release.

Unless we agree on something, and soon, that won't happen.  Your
workaround would break x[0] == x[0,:], so we're just swapping one set
of broken functionality for another.

I'm starting to see Chris Barker's point; allowing x[0] is causing
more problems than it is worth.  On the other hand, how would you
index into a vector (as in
http://en.wikipedia.org/wiki/Vector_(spatial)) without it?


More information about the Numpy-discussion mailing list