summaryrefslogtreecommitdiff
path: root/numpy/testing/utils.py
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/testing/utils.py')
-rw-r--r--numpy/testing/utils.py9
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: