summaryrefslogtreecommitdiff
path: root/numpy/core
diff options
context:
space:
mode:
authorJulian Taylor <jtaylor.debian@googlemail.com>2013-10-19 19:02:51 +0200
committerJulian Taylor <jtaylor.debian@googlemail.com>2013-10-19 19:04:28 +0200
commitb0dd6901d54e687571e44c4fa1d9c7db0d00e299 (patch)
treeb23f9caac031a8bc5c3926c3aa182ef87b0c59a7 /numpy/core
parent46a3fc10ef27be3637d72b5a6befb440a012dc87 (diff)
downloadnumpy-b0dd6901d54e687571e44c4fa1d9c7db0d00e299.tar.gz
ENH: accept callable as message in assert_
Allows deferring evaluation until failure. Used for blocked minmax test which evaluate array representations for the error message many thousand times accumulating to a full second useless runtime.
Diffstat (limited to 'numpy/core')
-rw-r--r--numpy/core/tests/test_umath.py7
1 files changed, 3 insertions, 4 deletions
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 7bcec3114..56e7311e2 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -678,10 +678,9 @@ class TestMinMax(TestCase):
for i in range(inp.size):
inp[:] = np.arange(inp.size, dtype=dt)
inp[i] = np.nan
- self.assertTrue(np.isnan(inp.max()),
- msg=repr(inp) + '\n' + msg)
- self.assertTrue(np.isnan(inp.min()),
- msg=repr(inp) + '\n' + msg)
+ emsg = lambda: '%r\n%s' % (inp, msg)
+ assert_(np.isnan(inp.max()), msg=emsg)
+ assert_(np.isnan(inp.min()), msg=emsg)
inp[i] = 1e10
assert_equal(inp.max(), 1e10, err_msg=msg)