diff options
author | Sebastian Berg <sebastian@sipsolutions.net> | 2017-08-07 21:14:58 +0200 |
---|---|---|
committer | Sebastian Berg <sebastian@sipsolutions.net> | 2017-08-07 21:44:40 +0200 |
commit | 95ffd706890c472a1c06e4e07cbe4f259407216e (patch) | |
tree | f9f4b64792fb56368dc134496cdf2036ee9b13ae /numpy/core/src/umath/loops.c.src | |
parent | 91b06c021319faccb008a8ee485d26ae227bf079 (diff) | |
download | python-numpy-95ffd706890c472a1c06e4e07cbe4f259407216e.tar.gz python-numpy-95ffd706890c472a1c06e4e07cbe4f259407216e.tar.bz2 python-numpy-95ffd706890c472a1c06e4e07cbe4f259407216e.zip |
BUG: The NAT deprecation warning should not be given for every single value
This fixes it so that it is at least only given for each inner loop run, which
admittingly slightly modifies the output on error (it will not stop at the first
NAT, but rather only after the first inner loop finished; this does not relaly
bother me though).
Closes gh-9528
Diffstat (limited to 'numpy/core/src/umath/loops.c.src')
-rw-r--r-- | numpy/core/src/umath/loops.c.src | 46 |
1 files changed, 26 insertions, 20 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src index 12c0d85ec..670c39ea2 100644 --- a/numpy/core/src/umath/loops.c.src +++ b/numpy/core/src/umath/loops.c.src @@ -1287,6 +1287,7 @@ NPY_NO_EXPORT void NPY_NO_EXPORT void @TYPE@_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)) { + npy_bool give_future_warning = 0; BINARY_LOOP { const @type@ in1 = *(@type@ *)ip1; const @type@ in2 = *(@type@ *)ip2; @@ -1294,17 +1295,19 @@ NPY_NO_EXPORT void *((npy_bool *)op1) = res; if ((in1 == NPY_DATETIME_NAT || in2 == NPY_DATETIME_NAT) && res) { - NPY_ALLOW_C_API_DEF - NPY_ALLOW_C_API; - /* 2016-01-18, 1.11 */ - if (DEPRECATE_FUTUREWARNING( - "In the future, 'NAT @OP@ x' and 'x @OP@ NAT' " - "will always be False.") < 0) { - NPY_DISABLE_C_API; - return; - } - NPY_DISABLE_C_API; + give_future_warning = 1; + } + } + if (give_future_warning) { + NPY_ALLOW_C_API_DEF + NPY_ALLOW_C_API; + /* 2016-01-18, 1.11 */ + if (DEPRECATE_FUTUREWARNING( + "In the future, 'NAT @OP@ x' and 'x @OP@ NAT' " + "will always be False.") < 0) { + /* nothing to do, we return anyway */ } + NPY_DISABLE_C_API; } } /**end repeat1**/ @@ -1312,23 +1315,26 @@ NPY_NO_EXPORT void NPY_NO_EXPORT void @TYPE@_not_equal(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func)) { + npy_bool give_future_warning = 0; BINARY_LOOP { const @type@ in1 = *(@type@ *)ip1; const @type@ in2 = *(@type@ *)ip2; *((npy_bool *)op1) = in1 != in2; if (in1 == NPY_DATETIME_NAT && in2 == NPY_DATETIME_NAT) { - NPY_ALLOW_C_API_DEF - NPY_ALLOW_C_API; - /* 2016-01-18, 1.11 */ - if (DEPRECATE_FUTUREWARNING( - "In the future, NAT != NAT will be True " - "rather than False.") < 0) { - NPY_DISABLE_C_API; - return; - } - NPY_DISABLE_C_API; + give_future_warning = 1; + } + } + if (give_future_warning) { + NPY_ALLOW_C_API_DEF + NPY_ALLOW_C_API; + /* 2016-01-18, 1.11 */ + if (DEPRECATE_FUTUREWARNING( + "In the future, NAT != NAT will be True " + "rather than False.") < 0) { + /* nothing to do, we return anyway */ } + NPY_DISABLE_C_API; } } |