summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2017-01-16 12:34:23 -0700
committerGitHub <noreply@github.com>2017-01-16 12:34:23 -0700
commitabb4b11ef7220a4e8a75b9a6a0eab0b5d1e3c06d (patch)
tree24040b04701b412bc38299e6bd4f726ef783fc38
parent5927539b311f656f9ec291b58b43bfc8c64b9e27 (diff)
parente0cf8393d3b7e8bb6ae9f7c9871bf0a90e3b4896 (diff)
downloadnumpy-abb4b11ef7220a4e8a75b9a6a0eab0b5d1e3c06d.tar.gz
Merge pull request #8483 from juliantaylor/nat-fixes
BUG: fix wrong future nat warning and equiv type logic error
-rw-r--r--numpy/core/src/multiarray/multiarraymodule.c4
-rw-r--r--numpy/core/src/umath/loops.c.src2
-rw-r--r--numpy/core/tests/test_datetime.py6
3 files changed, 8 insertions, 4 deletions
diff --git a/numpy/core/src/multiarray/multiarraymodule.c b/numpy/core/src/multiarray/multiarraymodule.c
index becd04370..a9ed5d198 100644
--- a/numpy/core/src/multiarray/multiarraymodule.c
+++ b/numpy/core/src/multiarray/multiarraymodule.c
@@ -1465,8 +1465,8 @@ PyArray_EquivTypes(PyArray_Descr *type1, PyArray_Descr *type2)
&& _equivalent_fields(type1->fields, type2->fields));
}
if (type_num1 == NPY_DATETIME
- || type_num1 == NPY_DATETIME
- || type_num2 == NPY_TIMEDELTA
+ || type_num1 == NPY_TIMEDELTA
+ || type_num2 == NPY_DATETIME
|| type_num2 == NPY_TIMEDELTA) {
return ((type_num1 == type_num2)
&& has_equivalent_datetime_metadata(type1, type2));
diff --git a/numpy/core/src/umath/loops.c.src b/numpy/core/src/umath/loops.c.src
index f76ae388b..86c9d494b 100644
--- a/numpy/core/src/umath/loops.c.src
+++ b/numpy/core/src/umath/loops.c.src
@@ -1226,7 +1226,7 @@ NPY_NO_EXPORT void
const @type@ in2 = *(@type@ *)ip2;
*((npy_bool *)op1) = in1 != in2;
- if (in1 == NPY_DATETIME_NAT && in1 == NPY_DATETIME_NAT) {
+ if (in1 == NPY_DATETIME_NAT && in2 == NPY_DATETIME_NAT) {
NPY_ALLOW_C_API_DEF
NPY_ALLOW_C_API;
/* 2016-01-18, 1.11 */
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index e443b3be0..94391f84c 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -1118,11 +1118,15 @@ class TestDateTime(TestCase):
assert_warns(FutureWarning, op, td_other, td_nat)
assert_warns(FutureWarning, np.not_equal, dt_nat, dt_nat)
+ assert_warns(FutureWarning, np.not_equal, td_nat, td_nat)
+
+ with suppress_warnings() as sup:
+ sup.record(FutureWarning)
assert_(np.not_equal(dt_nat, dt_other))
assert_(np.not_equal(dt_other, dt_nat))
- assert_warns(FutureWarning, np.not_equal, td_nat, td_nat)
assert_(np.not_equal(td_nat, td_other))
assert_(np.not_equal(td_other, td_nat))
+ self.assertEqual(len(sup.log), 0)
def test_datetime_minmax(self):
# The metadata of the result should become the GCD