From 2f1174dee44e901b7d028beb86f4a8ea324bd74f Mon Sep 17 00:00:00 2001 From: Charles Harris Date: Thu, 11 Jul 2013 16:49:04 -0600 Subject: MAINT: Use np.errstate context manager. Now that Python < 2.6 is no longer supported we can use the errstate context manager in places where constructs like ``` old = seterr(invalid='ignore') try: blah finally: seterr(**old) ``` were used. --- numpy/lib/tests/test_function_base.py | 5 +---- 1 file changed, 1 insertion(+), 4 deletions(-) (limited to 'numpy/lib/tests/test_function_base.py') diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 45e248913..a23e406e3 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -1062,8 +1062,7 @@ class TestHistogramdd(TestCase): def test_inf_edges(self): """Test using +/-inf bin edges works. See #1788.""" - olderr = np.seterr(invalid='ignore') - try: + with np.errstate(invalid='ignore'): 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]]) @@ -1072,8 +1071,6 @@ class TestHistogramdd(TestCase): 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): -- cgit v1.2.1