summaryrefslogtreecommitdiff
path: root/numpy/core/machar.py
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2013-07-11 16:49:04 -0600
committerCharles Harris <charlesr.harris@gmail.com>2013-07-11 16:49:04 -0600
commit2f1174dee44e901b7d028beb86f4a8ea324bd74f (patch)
tree8f09dc2bd35e2631f5821fe2e998f6ea46e254b8 /numpy/core/machar.py
parent49a587cd786242b05fcfd22d5cda961d733b68d4 (diff)
downloadnumpy-2f1174dee44e901b7d028beb86f4a8ea324bd74f.tar.gz
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.
Diffstat (limited to 'numpy/core/machar.py')
-rw-r--r--numpy/core/machar.py7
1 files changed, 2 insertions, 5 deletions
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