summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-01-18 15:30:37 -0700
committerCharles Harris <charlesr.harris@gmail.com>2016-01-18 19:09:28 -0700
commitae85a33e8f9be721361c8d5cb3f18eee8af30c44 (patch)
tree52292b33f84187e3a2e2f5a20e174e9ba6c0fcfa
parentaa824670cf6ad21c2f921856ba4eec00781347fe (diff)
downloadnumpy-ae85a33e8f9be721361c8d5cb3f18eee8af30c44.tar.gz
DEP: Emit FutureWarning for NAT comparisons.
In Numpy 1.13 the plan is for NAT comparisons to behave like NaN comparisons, e.g., False except for 'NAT != NAT', which will be True. See the discussion at gh-7019 for details.
-rw-r--r--numpy/core/src/umath/loops.c.src44
1 files changed, 41 insertions, 3 deletions
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index 2261a80db..7b8dcdbaf 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1117,8 +1117,8 @@ NPY_NO_EXPORT void
}
/**begin repeat1
- * #kind = equal, not_equal, greater, greater_equal, less, less_equal#
- * #OP = ==, !=, >, >=, <, <=#
+ * #kind = equal, greater, greater_equal, less, less_equal#
+ * #OP = ==, >, >=, <, <=#
*/
NPY_NO_EXPORT void
@TYPE@_@kind@(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
@@ -1126,11 +1126,49 @@ NPY_NO_EXPORT void
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
- *((npy_bool *)op1) = in1 @OP@ in2;
+ const npy_bool res = in1 @OP@ in2;
+ *((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;
+ }
}
}
/**end repeat1**/
+NPY_NO_EXPORT void
+@TYPE@_not_equal(char **args, npy_intp *dimensions, npy_intp *steps, void *NPY_UNUSED(func))
+{
+ BINARY_LOOP {
+ const @type@ in1 = *(@type@ *)ip1;
+ const @type@ in2 = *(@type@ *)ip2;
+ *((npy_bool *)op1) = in1 != in2;
+
+ if (in1 == NPY_DATETIME_NAT && in1 == 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;
+ }
+ }
+}
+
+
/**begin repeat1
* #kind = maximum, minimum#
* #OP = >, <#