diff options
author | David Cournapeau <cournape@gmail.com> | 2009-07-27 15:10:30 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2009-07-27 15:10:30 +0000 |
commit | 0d3aeb0dde468a15ad15a44017842115bc3313e4 (patch) | |
tree | 64c3bfa40774581eb1510facc038e55635ee21ac /numpy/testing/tests/test_utils.py | |
parent | 60fd0b786909db327fe4f3e925047e2c2f58f2d2 (diff) | |
download | numpy-0d3aeb0dde468a15ad15a44017842115bc3313e4.tar.gz |
Handle complex special values and negative zero.
Complex with nan/inf are correctly handled in assert_equal, as well as negative
zero.
Diffstat (limited to 'numpy/testing/tests/test_utils.py')
-rw-r--r-- | numpy/testing/tests/test_utils.py | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index e29edacff..240752dcf 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -145,6 +145,22 @@ class TestEqual(TestArrayEqual): self._assert_func('ab', 'ab') self._test_not_equal('ab', 'abb') + def test_complex_item(self): + self._assert_func(complex(1, 2), complex(1, 2)) + self._assert_func(complex(1, np.nan), complex(1, np.nan)) + self._test_not_equal(complex(1, np.nan), complex(1, 2)) + self._test_not_equal(complex(np.nan, 1), complex(1, np.nan)) + self._test_not_equal(complex(np.nan, np.inf), complex(np.nan, 2)) + + def test_negative_zero(self): + self._test_not_equal(np.PZERO, np.NZERO) + + def test_complex(self): + x = np.array([complex(1, 2), complex(1, np.nan)]) + y = np.array([complex(1, 2), complex(1, 2)]) + self._assert_func(x, x) + self._test_not_equal(x, y) + class TestArrayAlmostEqual(_GenericTest, unittest.TestCase): def setUp(self): self._assert_func = assert_array_almost_equal |