[Numpy-discussion] Matching 0-d arrays and NumPy scalars
Thu Feb 21 01:41:50 CST 2008
A Thursday 21 February 2008, Travis E. Oliphant escrigué:
> Hi everybody,
> In writing some generic code, I've encountered situations where it
> would reduce code complexity to allow NumPy scalars to be "indexed"
> in the same number of limited ways, that 0-d arrays support.
> For example, 0-d arrays can be indexed with
> * Boolean masks
> * Ellipses x[...] and x[..., newaxis]
> * Empty tuple x[()]
> I think that numpy scalars should also be indexable in these
> particular cases as well (read-only of course, i.e. no setting of
> the value would be possible).
> This is an easy change to implement, and I don't think it would cause
> any backward compatibility issues.
> Any opinions from the list?
Well, it seems like a non-intrusive modification, but I like the scalars
to remain un-indexable, mainly because it would be useful to raise an
error when you are trying to index them. In fact, I thought that when
you want a kind of scalar but indexable, you should use a 0-d array.
So, my vote is -0.
>0,0< Francesc Altet http://www.carabos.com/
V V Cárabos Coop. V. Enjoy Data
More information about the Numpy-discussion