summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2010-02-21 16:16:40 +0000
committerCharles Harris <charlesr.harris@gmail.com>2010-02-21 16:16:40 +0000
commit0bc06e1d4501f797b9fce40bb55bea2bf1476654 (patch)
treed87a565406455699ca12394b96608c9482829b18
parent52c43da079009c4b18ec5a7ac6bf31ef6cad69ed (diff)
downloadnumpy-0bc06e1d4501f797b9fce40bb55bea2bf1476654.tar.gz
BUG: More workarounds for np.isinf warning in tests.
-rw-r--r--numpy/core/tests/test_umath.py6
-rw-r--r--numpy/testing/utils.py24
2 files changed, 21 insertions, 9 deletions
diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py
index 37c819b8c..05aa360b7 100644
--- a/numpy/core/tests/test_umath.py
+++ b/numpy/core/tests/test_umath.py
@@ -232,7 +232,11 @@ def assert_hypot_isnan(x, y):
np.seterr(**err)
def assert_hypot_isinf(x, y):
- assert np.isinf(ncu.hypot(x, y)), "hypot(%s, %s) is %s, not inf" % (x, y, ncu.hypot(x, y))
+ err = np.seterr(invalid='ignore')
+ try:
+ assert np.isinf(ncu.hypot(x, y)), "hypot(%s, %s) is %s, not inf" % (x, y, ncu.hypot(x, y))
+ finally:
+ np.seterr(**err)
class TestHypotSpecialValues(TestCase):
def test_nan_outputs(self):
diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py
index f7fbbc2cb..745398dc3 100644
--- a/numpy/testing/utils.py
+++ b/numpy/testing/utils.py
@@ -61,10 +61,14 @@ def gisfinite(x):
exception is always raised.
This should be removed once this problem is solved at the Ufunc level."""
- from numpy.core import isfinite
- st = isfinite(x)
- if isinstance(st, types.NotImplementedType):
- raise TypeError("isfinite not supported for this type")
+ from numpy.core import isfinite, seterr
+ err = seterr(invalid='ignore')
+ try:
+ st = isfinite(x)
+ if isinstance(st, types.NotImplementedType):
+ raise TypeError("isfinite not supported for this type")
+ finally:
+ seterr(**err)
return st
def gisinf(x):
@@ -78,10 +82,14 @@ def gisinf(x):
exception is always raised.
This should be removed once this problem is solved at the Ufunc level."""
- from numpy.core import isinf
- st = isinf(x)
- if isinstance(st, types.NotImplementedType):
- raise TypeError("isinf not supported for this type")
+ from numpy.core import isinf, seterr
+ err = seterr(invalid='ignore')
+ try:
+ st = isinf(x)
+ if isinstance(st, types.NotImplementedType):
+ raise TypeError("isinf not supported for this type")
+ finally:
+ seterr(**err)
return st
def rand(*args):