Skip to content

Commit

Permalink
BUG: fix wrong future nat warning and equiv type logic error
Browse files Browse the repository at this point in the history
  • Loading branch information
juliantaylor committed Jan 16, 2017
1 parent a5d71d6 commit e0cf839
Show file tree
Hide file tree
Showing 3 changed files with 8 additions and 4 deletions.
4 changes: 2 additions & 2 deletions numpy/core/src/multiarray/multiarraymodule.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
Expand Down
2 changes: 1 addition & 1 deletion numpy/core/src/umath/loops.c.src
Original file line number Diff line number Diff line change
Expand Up @@ -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 */
Expand Down
6 changes: 5 additions & 1 deletion numpy/core/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -1118,11 +1118,15 @@ def test_datetime_compare_nat(self):
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
Expand Down

0 comments on commit e0cf839

Please sign in to comment.