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

Francesc Altet faltet@carabos....
Fri Feb 22 10:34:44 CST 2008


A Thursday 21 February 2008, Konrad Hinsen escrigué:
> I agree. In fact, I'd rather see NumPy scalars move towards Python
> scalars rather than towards NumPy arrays in behaviour. In particular,
> their nasty habit of coercing everything they are combined with into
> arrays is still my #1 source of compatibility problems with porting
> code from Numeric to NumPy. I end up converting NumPy scalars to
> Python scalars explicitly in lots of places.

Yeah, that happened to me too quite frequently, and it is quite 
uncomfortable.  Also, I find this specially unpleasant:

In [87]: numpy.int(1)/numpy.uint64(2)
Out[87]: 0.5

Is this avoidable, or it's a consequence of the coercing rules?  I guess 
this is the same case of:

In [88]: numpy.array([1])/numpy.array([2], 'uint64')
Out[88]: array([ 0.5])

By the way:

In [89]: numpy.array(1)/numpy.array(2, 'uint64')
Out[89]: 0.5

shouldn't this be array(0.5)?

Cheers,

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


More information about the Numpy-discussion mailing list