[Numpy-discussion] Scalars, comparisons and indexing. Is this a bug?

Fernando Perez fperez.net at gmail.com
Fri Jul 14 20:36:09 CDT 2006

On 7/14/06, Bill Baxter <wbaxter at gmail.com> wrote:
> I believe that's the problem that the indexing PEP from Travis is
> supposed to address:
>   http://www.python.org/dev/peps/pep-0357/
> So I think there's not much anyone can do about it untill the PEP is
> accepted and implemented.
> Maybe you can cast to int?
> > In [34]: (1,2)[int(a[0]==b)]

Yup, that's the workaround I'm using.

I was just wondering if comparisons between array scalars shouldn't
return /true/ booleans (which can be used as indices) instead of array
scalar booleans.  I realize that the __index__ support in 2.5 will
make this point moot (the PEP you point to), but perhaps this
particular one can actually be fixed today, for all users of python
pre-2.5.  However, I haven't really wrapped my head enough around all
the subtleties of array scalars to know whether 'fixing' this
particular problem will introduce other, worse ones.



More information about the Numpy-discussion mailing list