summaryrefslogtreecommitdiff
path: root/numpy/testing
diff options
context:
space:
mode:
authorPatrick Peglar <patrick.peglar@metoffice.gov.uk>2014-08-31 15:43:39 +0100
committerPatrick Peglar <patrick.peglar@metoffice.gov.uk>2014-08-31 15:43:39 +0100
commit4097ec3ec10c41d399518867f4bebb0a53ee8a5c (patch)
tree0e4662c49fb39113c82965588f7d3128bb8fa982 /numpy/testing
parent9c50f988ac27dd1758dbc46455573aaa77638c68 (diff)
downloadnumpy-4097ec3ec10c41d399518867f4bebb0a53ee8a5c.tar.gz
BUG: fix percentage reporting when testing.assert_allclose fails.
Diffstat (limited to 'numpy/testing')
-rw-r--r--numpy/testing/tests/test_utils.py5
-rw-r--r--numpy/testing/utils.py2
2 files changed, 6 insertions, 1 deletions
diff --git a/numpy/testing/tests/test_utils.py b/numpy/testing/tests/test_utils.py
index aa0a2669f..c1d0e83da 100644
--- a/numpy/testing/tests/test_utils.py
+++ b/numpy/testing/tests/test_utils.py
@@ -449,6 +449,11 @@ class TestAssertAllclose(unittest.TestCase):
# Should not raise:
assert_allclose(a, a)
+ def test_report_fail_percentage(self):
+ a = np.array([1, 1, 1, 1])
+ b = np.array([1, 1, 1, 2])
+ with self.assertRaisesRegexp(AssertionError, "25.0%"):
+ assert_allclose(a, b)
class TestArrayAlmostEqualNulp(unittest.TestCase):
@dec.knownfailureif(True, "Github issue #347")
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index bd184d922..71c7145f9 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -1289,7 +1289,7 @@ def assert_allclose(actual, desired, rtol=1e-7, atol=0,
"""
import numpy as np
def compare(x, y):
- return np.allclose(x, y, rtol=rtol, atol=atol)
+ return np.core.numeric._allclose_points(x, y, rtol=rtol, atol=atol)
actual, desired = np.asanyarray(actual), np.asanyarray(desired)
header = 'Not equal to tolerance rtol=%g, atol=%g' % (rtol, atol)