summaryrefslogtreecommitdiff
path: root/numpy/core/src
diff options
context:
space:
mode:
authorStephan Hoyer <shoyer@climate.com>2016-01-12 20:44:34 -0800
committerStephan Hoyer <shoyer@climate.com>2016-01-14 13:44:43 -0800
commit53ad26a84ac2aa6f5a37f09aa9feae5afed44f79 (patch)
tree856886f3b9d65fb6305f21f9d692cb0861b861cb /numpy/core/src
parent8fa6e3bef26a6d4a2c92f2824129aa4409be2590 (diff)
downloadnumpy-53ad26a84ac2aa6f5a37f09aa9feae5afed44f79.tar.gz
TST, ENH: make all comparisons with NaT false
Now, NaT compares like NaN: - NaT != NaT -> True - NaT == NaT (and all other comparisons) -> False We discussed this on the mailing list back in October: https://mail.scipy.org/pipermail/numpy-discussion/2015-October/073968.html
Diffstat (limited to 'numpy/core/src')
-rw-r--r--numpy/core/src/multiarray/scalartypes.c.src2
-rw-r--r--numpy/core/src/umath/loops.c.src26
2 files changed, 24 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/scalartypes.c.src b/numpy/core/src/multiarray/scalartypes.c.src
index 1bd5b22d2..7c73822dd 100644
--- a/numpy/core/src/multiarray/scalartypes.c.src
+++ b/numpy/core/src/multiarray/scalartypes.c.src
@@ -1673,7 +1673,7 @@ voidtype_setfield(PyVoidScalarObject *self, PyObject *args, PyObject *kwds)
* However, as a special case, void-scalar assignment broadcasts
* differently from ndarrays when assigning to an object field: Assignment
* to an ndarray object field broadcasts, but assignment to a void-scalar
- * object-field should not, in order to allow nested ndarrays.
+ * object-field should not, in order to allow nested ndarrays.
* These lines should then behave identically:
*
* b = np.zeros(1, dtype=[('x', 'O')])
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index fc9ffec94..563761bc0 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,31 @@ NPY_NO_EXPORT void
BINARY_LOOP {
const @type@ in1 = *(@type@ *)ip1;
const @type@ in2 = *(@type@ *)ip2;
- *((npy_bool *)op1) = in1 @OP@ in2;
+ if (in1 == NPY_DATETIME_NAT || in2 == NPY_DATETIME_NAT) {
+ *((npy_bool *)op1) = NPY_FALSE;
+ }
+ else {
+ *((npy_bool *)op1) = in1 @OP@ in2;
+ }
}
}
/**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;
+ if (in1 == NPY_DATETIME_NAT || in2 == NPY_DATETIME_NAT) {
+ *((npy_bool *)op1) = NPY_TRUE;
+ }
+ else {
+ *((npy_bool *)op1) = in1 != in2;
+ }
+ }
+}
+
/**begin repeat1
* #kind = maximum, minimum#
* #OP = >, <#