[Numpy-discussion] A case for rank-0 arrays

Francesc Altet faltet at carabos.com
Fri Feb 24 00:53:02 CST 2006

A Divendres 24 Febrer 2006 06:07, Travis Oliphant va escriure:
> Sasha wrote:
> >>>>type(array(2)*2)
> >
> ><type 'int32scalar'>
> >
> >I believe it should result in a rank-0 array instead.

Yes, this sounds reasonable, IMHO.

> Right now the rule is basically:
> rank-0 arrays become array-scalars all the time.
> The exceptions are
> rank0.copy()
> rank0.view()
> array(5)
> scalar.__array__()
> one_el.shape=()
> If you can come up with a clear set of rules for when rank-0 arrays
> should show up and when scalars should show up, then we will understand
> better what you want to do.

Yeah. I think Travis is right. A set of rules clearly stating the
situations where rank-0 arrays have to become scalars maybe worth the
effort. Travis already has the above list and now is just a matter of
discovering other exceptions that should go there. So, please, if
anybody comes with more exceptions, go ahead and propose them.


>0,0<   Francesc Altet     http://www.carabos.com/
V   V   Cárabos Coop. V.   Enjoy Data

More information about the Numpy-discussion mailing list