diff options
author | Nathaniel J. Smith <njs@pobox.com> | 2012-09-20 22:03:31 +0100 |
---|---|---|
committer | Nathaniel J. Smith <njs@pobox.com> | 2012-09-20 22:45:00 +0100 |
commit | cea0a209875be753a74b8c7bb02aa9531726ee98 (patch) | |
tree | 4545b54b81e72a448aa4d68a02250c5b045f6915 /numpy/polynomial/polyutils.py | |
parent | 47086158cb00a151b67c442ae759ce230ec0de34 (diff) | |
download | numpy-cea0a209875be753a74b8c7bb02aa9531726ee98.tar.gz |
FIX: Transition scheme for safer in-place ufunc operations
In numpy 1.6 and earlier, if you do
np.add(int_arr, float_arr, out=int_arr)
or
int_arr += float_arr
then the result will be silently truncated to integer values. This
often produces bugs, because it's easy to accidentally end up with an
integer array and not realize it.
Therefore, there seems to be consensus that we should switch to using
same_kind casting by default for in-place ufunc operations. However,
just switching this (as was done initially during the 1.7 development
cycle) breaks a lot of code, which is rude and violates our
deprecation policy.
This commit instead adds a special temporary casting rule which acts
like "unsafe", but also checks whether each operation would be allowed
under "same_kind" rules and issues a DeprecationWarning if not.
It also moves NPY_DEFAULT_ASSIGN_CASTING into the formal API instead
of leaving it as a #define. This way we can change it later, and any
code which references it and is compiled against this version of numpy
will automatically switch to whatever we change it too. This avoids
the situation where we want to remove the temporary magic value we're
using to create DeprecationWarnings now, but can't because it would be
an ABI break.
Diffstat (limited to 'numpy/polynomial/polyutils.py')
0 files changed, 0 insertions, 0 deletions