[Numpy-discussion] Matching 0-d arrays and NumPy scalars

Travis E. Oliphant oliphant@enthought....
Wed Feb 20 22:14:07 CST 2008


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?


Best regards,

-Travis O.





More information about the Numpy-discussion mailing list