summaryrefslogtreecommitdiff
path: root/numpy/testing/tests/test_utils.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-01-14 16:32:57 -0700
committerCharles Harris <charlesr.harris@gmail.com>2016-01-14 16:32:57 -0700
commit7141f40b58ed1e7071cde78ab7bc8ab37e9c5983 (patch)
tree856886f3b9d65fb6305f21f9d692cb0861b861cb /numpy/testing/tests/test_utils.py
parent8fa6e3bef26a6d4a2c92f2824129aa4409be2590 (diff)
parent53ad26a84ac2aa6f5a37f09aa9feae5afed44f79 (diff)
downloadnumpy-7141f40b58ed1e7071cde78ab7bc8ab37e9c5983.tar.gz
Merge pull request #7001 from shoyer/NaT-comparison
API: make all comparisons with NaT false
Diffstat (limited to 'numpy/testing/tests/test_utils.py')
-rw-r--r--numpy/testing/tests/test_utils.py33
1 files changed, 31 insertions, 2 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 23bd491bc..92a00f712 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -11,7 +11,7 @@ from numpy.testing import (
assert_warns, assert_no_warnings, assert_allclose, assert_approx_equal,
assert_array_almost_equal_nulp, assert_array_max_ulp,
clear_and_catch_warnings, run_module_suite,
- assert_string_equal, assert_, tempdir, temppath,
+ assert_string_equal, assert_, tempdir, temppath,
)
import unittest
@@ -119,6 +119,25 @@ class TestArrayEqual(_GenericTest, unittest.TestCase):
c = np.array([1, 2, 3])
self._test_not_equal(c, b)
+ def test_nat_array_datetime(self):
+ a = np.array([np.datetime64('2000-01'), np.datetime64('NaT')])
+ b = np.array([np.datetime64('2000-01'), np.datetime64('NaT')])
+ self._test_equal(a, b)
+
+ c = np.array([np.datetime64('NaT'), np.datetime64('NaT')])
+ self._test_not_equal(c, b)
+
+ def test_nat_array_timedelta(self):
+ a = np.array([np.timedelta64(1, 'h'), np.timedelta64('NaT')])
+ b = np.array([np.timedelta64(1, 'h'), np.timedelta64('NaT')])
+ self._test_equal(a, b)
+
+ c = np.array([np.timedelta64('NaT'), np.timedelta64('NaT')])
+ self._test_not_equal(c, b)
+
+ d = np.array([np.datetime64('NaT'), np.datetime64('NaT')])
+ self._test_not_equal(c, d)
+
def test_string_arrays(self):
"""Test two arrays with different shapes are found not equal."""
a = np.array(['floupi', 'floupa'])
@@ -227,6 +246,16 @@ class TestEqual(TestArrayEqual):
self._assert_func(x, x)
self._test_not_equal(x, y)
+ def test_nat(self):
+ dt = np.datetime64('2000-01-01')
+ dt_nat = np.datetime64('NaT')
+ td_nat = np.timedelta64('NaT')
+ self._assert_func(dt_nat, dt_nat)
+ self._assert_func(td_nat, td_nat)
+ self._test_not_equal(dt_nat, td_nat)
+ self._test_not_equal(dt, td_nat)
+ self._test_not_equal(dt, dt_nat)
+
class TestArrayAlmostEqual(_GenericTest, unittest.TestCase):
@@ -457,7 +486,7 @@ class TestWarns(unittest.TestCase):
class TestAssertAllclose(unittest.TestCase):
-
+
def test_simple(self):
x = 1e-3
y = 1e-9