diff options
-rw-r--r-- | numpy/core/tests/test_numeric.py | 6 | ||||
-rw-r--r-- | numpy/core/tests/test_regression.py | 12 | ||||
-rw-r--r-- | numpy/core/tests/test_umath.py | 2 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 20 |
4 files changed, 27 insertions, 13 deletions
diff --git a/numpy/core/tests/test_numeric.py b/numpy/core/tests/test_numeric.py index 205bf56c4..de41f0c1f 100644 --- a/numpy/core/tests/test_numeric.py +++ b/numpy/core/tests/test_numeric.py @@ -1159,6 +1159,12 @@ class TestAllclose(object): rtol = 1e-5 atol = 1e-8 + def setUp(self): + self.olderr = np.seterr(invalid='ignore') + + def tearDown(self): + np.seterr(**self.olderr) + def tst_allclose(self,x,y): assert_(allclose(x,y), "%s and %s not close" % (x,y)) diff --git a/numpy/core/tests/test_regression.py b/numpy/core/tests/test_regression.py index 55d5b6ec6..c03c5b02f 100644 --- a/numpy/core/tests/test_regression.py +++ b/numpy/core/tests/test_regression.py @@ -1003,10 +1003,14 @@ class TestRegression(TestCase): def test_sign_for_complex_nan(self, level=rlevel): """Ticket 794.""" - C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) - have = np.sign(C) - want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan]) - assert_equal(have, want) + olderr = np.seterr(invalid='ignore') + try: + C = np.array([-np.inf, -2+1j, 0, 2-1j, np.inf, np.nan]) + have = np.sign(C) + want = np.array([-1+0j, -1+0j, 0+0j, 1+0j, 1+0j, np.nan]) + assert_equal(have, want) + finally: + np.seterr(**olderr) def test_for_equal_names(self, level=rlevel): """Ticket #674""" diff --git a/numpy/core/tests/test_umath.py b/numpy/core/tests/test_umath.py index 5d3f160da..1ac958be7 100644 --- a/numpy/core/tests/test_umath.py +++ b/numpy/core/tests/test_umath.py @@ -10,7 +10,7 @@ class _FilterInvalids(): self.olderr = np.seterr(invalid='ignore') def tearDown(self): - np.seterr(**olderr) + np.seterr(**self.olderr) class TestDivision(TestCase): diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index fc033b164..a7d501c52 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -784,14 +784,18 @@ class TestHistogramdd(TestCase): def test_inf_edges(self): """Test using +/-inf bin edges works. See #1788.""" - x = np.arange(6).reshape(3, 2) - expected = np.array([[1, 0], [0, 1], [0, 1]]) - h, e = np.histogramdd(x, bins=[3, [-np.inf, 2, 10]]) - assert_allclose(h, expected) - h, e = np.histogramdd(x, bins=[3, np.array([-1, 2, np.inf])]) - assert_allclose(h, expected) - h, e = np.histogramdd(x, bins=[3, [-np.inf, 3, np.inf]]) - assert_allclose(h, expected) + olderr = np.seterr(invalid='ignore') + try: + x = np.arange(6).reshape(3, 2) + expected = np.array([[1, 0], [0, 1], [0, 1]]) + h, e = np.histogramdd(x, bins=[3, [-np.inf, 2, 10]]) + assert_allclose(h, expected) + h, e = np.histogramdd(x, bins=[3, np.array([-1, 2, np.inf])]) + assert_allclose(h, expected) + h, e = np.histogramdd(x, bins=[3, [-np.inf, 3, np.inf]]) + assert_allclose(h, expected) + finally: + np.seterr(**olderr) class TestUnique(TestCase): |