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/core/machar.py | 7 ++----- 1 file changed, 2 insertions(+), 5 deletions(-) (limited to 'numpy/core/machar.py') diff --git a/numpy/core/machar.py b/numpy/core/machar.py index 85eb6b625..9eb4430a6 100644 --- a/numpy/core/machar.py +++ b/numpy/core/machar.py @@ -10,7 +10,7 @@ from __future__ import division, absolute_import, print_function __all__ = ['MachAr'] from numpy.core.fromnumeric import any -from numpy.core.numeric import seterr +from numpy.core.numeric import errstate # Need to speed this up...especially for longfloat @@ -107,11 +107,8 @@ class MachAr(object): """ # We ignore all errors here because we are purposely triggering # underflow to detect the properties of the runninng arch. - saverrstate = seterr(under='ignore') - try: + with errstate(under='ignore'): self._do_init(float_conv, int_conv, float_to_float, float_to_str, title) - finally: - seterr(**saverrstate) def _do_init(self, float_conv, int_conv, float_to_float, float_to_str, title): max_iterN = 10000 -- cgit v1.2.1