[Numpy-discussion] Fixed scalar coercion model in NumPy

Travis Oliphant oliphant@ee.byu....
Mon Mar 26 15:52:28 CDT 2007


I've finally made the changes to fix the scalar coercion model problems 
in NumPy 1.0.1

Now, scalar coercion rules only apply when involved types are of the 
same basic "kind".

Thus,

array([1,2,3],int8)*10

returns an int8 array

but

array([1,2,3],int8)*10.0

returns a float64 array.

If you want a float32 array you must use

array([1,2,3],int8)*float32(10.0)


This is actually a behavioral change which is why I asked earlier if we 
should change it.  However, the previous behavior was not documented 
anywhere and any previous discussion on this point should have been 
interpreted as the behavior now in SVN.

It's also a rare use-case and so should not create too many issues.
In running tests with NumPy and SciPy there appear to be three tests in 
ndimage breaking now.

I really do want to get 1.0.2 out the door soon.  What still needs to be 
fixed before then?

-Travis



More information about the Numpy-discussion mailing list