I never noticed this kind of cast before (1.8.0), it's just a bit surprising.

It was convenient to write translations (for a bunch of points) such as:

Z = np.ones((n,2),dtype=np.float32) + (300,300)

but I can live with Z += 300,300


Nicolas


On 03 Mar 2014, at 23:02, Benjamin Root <[email protected]> wrote:

> IIRC, this is dependent on whether you are using 32bit versus 64bit numpy. 
> All regular integer numbers can fit in 32 bits (is that right?), but the 1.1 
> is treated as a float32 if on a 32 bit NumPy or as float64 if on a 64 bit 
> NumPy.
> 
> That's my stab at it.
> 
> Ben Root
> 
> 
> On Mon, Mar 3, 2014 at 4:06 PM, Nicolas Rougier <[email protected]> 
> wrote:
> 
> Hi all,
> 
> I'm using numpy 1.8.0 (osx 10.9, python 2.7.6) and I can't understand dtype 
> promotion in the following case:
> 
> >>> Z = np.zeros((2,2),dtype=np.float32) + 1
> >>> print Z.dtype
> float32
> 
> >>> Z = np.zeros((2,2),dtype=np.float32) + (1,1)
> >>> print Z.dtype
> float64
> 
> 
> Is this the expected behavior ?
> What it the difference between the two lines ?
> 
> 
> 
> Nicolas
> _______________________________________________
> NumPy-Discussion mailing list
> [email protected]
> http://mail.scipy.org/mailman/listinfo/numpy-discussion
> 
> _______________________________________________
> NumPy-Discussion mailing list
> [email protected]
> http://mail.scipy.org/mailman/listinfo/numpy-discussion

_______________________________________________
NumPy-Discussion mailing list
[email protected]
http://mail.scipy.org/mailman/listinfo/numpy-discussion

Reply via email to