From b0dd6901d54e687571e44c4fa1d9c7db0d00e299 Mon Sep 17 00:00:00 2001 From: Julian Taylor Date: Sat, 19 Oct 2013 19:02:51 +0200 Subject: 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. --- numpy/core/tests/test_umath.py | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) (limited to 'numpy/core') 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) -- cgit v1.2.1