[Numpy-discussion] tighten up ufunc casting rule
Thu Jun 2 15:06:58 CDT 2011
Would anyone object to, at least temporarily, tightening up the default
ufunc casting rule to 'same_kind' in NumPy master? It's a one line change,
so would be easy to undo, but such a change is very desirable in my opinion.
This would raise an exception, since it's np.add(a, 1.9, out=a), converting
a float to an int:
>>> a = np.arange(3, dtype=np.int32)
>>> a += 1.9
It's also relevant to the discussion of nonlinear datetime units and
datetime in general. Currently, it will silently convert a months or years
delta to a days delta. I've made the conversions between non-linear metadata
not satisfy the 'same_kind' rule, so they would be disallowed by default as
well (but easily enabled with a casting='unsafe' parameter).
By doing this change, we can see what other code it affects, such as scipy,
and patch that code to be safe for this convention whether or not it is
adopted in the next release.
-------------- next part --------------
An HTML attachment was scrubbed...
More information about the NumPy-Discussion