diff options
author | Charles Harris <charlesr.harris@gmail.com> | 2010-02-21 23:17:54 +0000 |
---|---|---|
committer | Charles Harris <charlesr.harris@gmail.com> | 2010-02-21 23:17:54 +0000 |
commit | 89147a16a8f57bf7650cd50872f46c64c528af60 (patch) | |
tree | 199d96257372140062096fb828c8ffc67ede7ca0 /numpy/testing/utils.py | |
parent | 50375e7ea744fe685abd0623446f45de2019437a (diff) | |
download | numpy-89147a16a8f57bf7650cd50872f46c64c528af60.tar.gz |
BUG: Ignore "invalid value" from abs in testing/utils.py
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r-- | numpy/testing/utils.py | 9 |
1 files changed, 7 insertions, 2 deletions
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: |