From 0bc06e1d4501f797b9fce40bb55bea2bf1476654 Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Sun, 21 Feb 2010 16:16:40 +0000 Subject: BUG: More workarounds for np.isinf warning in tests. --- numpy/testing/utils.py | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) (limited to 'numpy/testing') 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): -- cgit v1.2.1