Fixed scalar coercion model in NumPy
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
Perry Greenfield wrote:
Great!
On Mar 26, 2007, at 4:52 PM, Travis Oliphant wrote:
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".
Actually, the rule is better stated. The scalar coercion rules apply when involved types are of the same basic "kind" or if the scalar is of "lesser" kind than the array. Thus, array([1,2,3],float32)*10 produces a float32 array array([1,2,3],float32)*10.0 produces a float32 array array([1,2,3],float32)*10.0j produces a complex128 array -Travis
participants (3)
-
Perry Greenfield
-
Stefan van der Walt
-
Travis Oliphant