From 89147a16a8f57bf7650cd50872f46c64c528af60 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 21 Feb 2010 23:17:54 +0000 Subject: BUG: Ignore "invalid value" from abs in testing/utils.py --- numpy/testing/utils.py | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) (limited to 'numpy/testing/utils.py') diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 745398dc3..875027cd8 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -521,8 +521,13 @@ def assert_approx_equal(actual,desired,significant=7,err_msg='',verbose=True): return # Normalized the numbers to be in range (-10.0,10.0) # scale = float(pow(10,math.floor(math.log10(0.5*(abs(desired)+abs(actual)))))) - scale = 0.5*(np.abs(desired) + np.abs(actual)) - scale = np.power(10,np.floor(np.log10(scale))) + err = np.seterr(invalid='ignore') + try: + scale = 0.5*(np.abs(desired) + np.abs(actual)) + scale = np.power(10,np.floor(np.log10(scale))) + finally: + np.seterr(**err) + try: sc_desired = desired/scale except ZeroDivisionError: -- cgit v1.2.1