diff options
author | David Cournapeau <cournape@gmail.com> | 2008-04-08 18:04:33 +0000 |
---|---|---|
committer | David Cournapeau <cournape@gmail.com> | 2008-04-08 18:04:33 +0000 |
commit | 2ba8132b518e08c6b25e54df0a025cf9aa006f06 (patch) | |
tree | a1466fea8cf1635ac4ffd8311050f6d9f4c625cb | |
parent | 0035f9187945a7d787bcadad38cfb84ca196bc18 (diff) | |
download | numpy-2ba8132b518e08c6b25e54df0a025cf9aa006f06.tar.gz |
Fix test for assert* with nan values + string formatting issue when handling nan.
-rw-r--r-- | numpy/testing/tests/test_utils.py | 11 | ||||
-rw-r--r-- | numpy/testing/utils.py | 4 |
2 files changed, 9 insertions, 6 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py index 154c3f03e..48cd89cdd 100644 --- a/numpy/testing/tests/test_utils.py +++ b/numpy/testing/tests/test_utils.py @@ -90,11 +90,14 @@ class TestEqual(_GenericTest): foo(t) def test_nan_array(self): - """Test two arrays with different shapes are found not equal.""" - a = N.array([1, 2]) - b = N.array([[1, 2], [1, 2]]) + """Test arrays with nan values in them.""" + a = N.array([1, 2, N.nan]) + b = N.array([1, 2, N.nan]) - self._test_not_equal(a, b) + self._test_equal(a, b) + + c = N.array([1, 2, 3]) + self._test_not_equal(c, b) def test_string_arrays(self): """Test two arrays with different shapes are found not equal.""" diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 654d55738..ab8d77b76 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -216,8 +216,8 @@ def assert_array_compare(comparison, x, y, err_msg='', verbose=True, except AssertionError: msg = build_err_msg([x, y], err_msg - + '\n(x and y nan location mismatch %s, ' - + '%s mismatch)' % (xnanid, ynanid), + + '\n(x and y nan location mismatch %s, ' \ + '%s mismatch)' % (xnanid, ynanid), verbose=verbose, header=header, names=('x', 'y')) val = comparison(x[~xnanid], y[~ynanid]) |