summaryrefslogtreecommitdiff
path: root/numpy
diff options
context:
space:
mode:
authorDavid Cournapeau <cournape@gmail.com>2009-07-27 08:07:07 +0000
committerDavid Cournapeau <cournape@gmail.com>2009-07-27 08:07:07 +0000
commit56caa44161152ffd4f354757c8d4d42007413f79 (patch)
tree0665e5c878ff5d34ef0be675c47cac8d408470d8 /numpy
parentf49d6d36b666eaff6a82614badf452df1844e33b (diff)
downloadnumpy-56caa44161152ffd4f354757c8d4d42007413f79.tar.gz
BUG: assert_array_compare did not raise an exception when the nan indexes of both arguments did not match.
Diffstat (limited to 'numpy')
-rw-r--r--numpy/testing/tests/test_utils.py12
-rw-r--r--numpy/testing/utils.py1
2 files changed, 13 insertions, 0 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index 1703ddbc7..b8aaa4de4 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -131,6 +131,18 @@ class TestArrayAlmostEqual(_GenericTest, unittest.TestCase):
def setUp(self):
self._assert_func = assert_array_almost_equal
+ def test_nan(self):
+ anan = np.array([np.nan])
+ aone = np.array([1])
+ ainf = np.array([np.inf])
+ self._assert_func(anan, anan)
+ self.failUnlessRaises(AssertionError,
+ lambda : self._assert_func(anan, aone))
+ self.failUnlessRaises(AssertionError,
+ lambda : self._assert_func(anan, ainf))
+ self.failUnlessRaises(AssertionError,
+ lambda : self._assert_func(ainf, anan))
+
class TestAlmostEqual(_GenericTest, unittest.TestCase):
def setUp(self):
self._assert_func = assert_almost_equal
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index b18cef6e3..9928bbb90 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -423,6 +423,7 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True,
'%s mismatch)' % (xnanid, ynanid),
verbose=verbose, header=header,
names=('x', 'y'))
+ raise AssertionError(msg)
val = comparison(x[~xnanid], y[~ynanid])
else:
val = comparison(x,y)