summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-01-18 19:07:12 -0700
committerCharles Harris <charlesr.harris@gmail.com>2016-01-18 19:09:34 -0700
commit31dbc05d86c4018c76562466de0ea569eb1f8a62 (patch)
tree39b37651ba4502d39b36706d30f42bc7a23f5244 /numpy/core
parentae85a33e8f9be721361c8d5cb3f18eee8af30c44 (diff)
downloadnumpy-31dbc05d86c4018c76562466de0ea569eb1f8a62.tar.gz
TST: Add tests for NAT comparison FutureWarning.
The behavior of NAT comparisons will change in Numpy 1.13. Make sure that a FutureWarning is emitted when the results will change.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/test_datetime.py28
1 files changed, 28 insertions, 0 deletions
diff --git a/numpy/core/tests/test_datetime.py b/numpy/core/tests/test_datetime.py
index 8aeaf51ac..601f09c09 100644
--- a/numpy/core/tests/test_datetime.py
+++ b/numpy/core/tests/test_datetime.py
@@ -1086,6 +1086,34 @@ class TestDateTime(TestCase):
assert_equal(np.greater(a, b), [0, 1, 0, 1, 0])
assert_equal(np.greater_equal(a, b), [1, 1, 0, 1, 0])
+ def test_datetime_compare_nat(self):
+ dt_nat = np.datetime64('NaT', 'D')
+ dt_other = np.datetime64('2000-01-01')
+ td_nat = np.timedelta64('NaT', 'h')
+ td_other = np.timedelta64(1, 'h')
+
+ for op in [np.equal, np.less, np.less_equal,
+ np.greater, np.greater_equal]:
+ if op(dt_nat, dt_nat):
+ assert_warns(FutureWarning, op, dt_nat, dt_nat)
+ if op(dt_nat, dt_other):
+ assert_warns(FutureWarning, op, dt_nat, dt_other)
+ if op(dt_other, dt_nat):
+ assert_warns(FutureWarning, op, dt_other, dt_nat)
+ if op(td_nat, td_nat):
+ assert_warns(FutureWarning, op, td_nat, td_nat)
+ if op(td_nat, td_other):
+ assert_warns(FutureWarning, op, td_nat, td_other)
+ if op(td_other, td_nat):
+ assert_warns(FutureWarning, op, td_other, td_nat)
+
+ assert_warns(FutureWarning, np.not_equal, dt_nat, dt_nat)
+ 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))
+
def test_datetime_minmax(self):
# The metadata of the result should become the GCD
# of the operand metadata