summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2017-01-16 19:09:03 +0100
committerJulian Taylor <jtaylor.debian@googlemail.com>2017-01-16 19:09:42 +0100
commite0cf8393d3b7e8bb6ae9f7c9871bf0a90e3b4896 (patch)
treed0b255a32d6d021cadfda84eb938063e9a21cc1c /numpy
parenta5d71d64a0d2e7a50562df80349219080172f254 (diff)
downloadnumpy-e0cf8393d3b7e8bb6ae9f7c9871bf0a90e3b4896.tar.gz
BUG: fix wrong future nat warning and equiv type logic error
Diffstat (limited to 'numpy')
-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