summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-04-18 19:07:59 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-04-18 19:07:59 +0000
commit07e5091227397cdec85d0b07e9a7cbc34ab257ed (patch)
tree20fa7de6d3a4a6f350e9c1e8418f84ead08aee85 /numpy/core/numeric.py
parente273a1abc85f55719a1f3ff247372be6274522b1 (diff)
downloadnumpy-07e5091227397cdec85d0b07e9a7cbc34ab257ed.tar.gz
Implement a reset-on-delete object for save error modes.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py16
1 files changed, 12 insertions, 4 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index f3236cdb1..af4f3e6f8 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -395,6 +395,14 @@ def allclose (a, b, rtol=1.e-5, atol=1.e-8):
return d.ravel().all()
+class ufunc_values_obj(object):
+ def __init__(self, obj):
+ self._val_obj = obj
+ def __del__(self):
+ umath.seterrobj(self._val_obj)
+ del self._val_obj
+
+
_errdict = {"ignore":ERR_IGNORE,
"warn":ERR_WARN,
"raise":ERR_RAISE,
@@ -415,9 +423,9 @@ def seterr(divide="ignore", over="ignore", under="ignore",
pyvals = umath.geterrobj()
old = pyvals[:]
- pyvals[1] = maskvalue
+ pyvals[1] = maskvalue
umath.seterrobj(pyvals)
- return old
+ return ufunc_values_obj(old)
def geterr():
maskvalue = umath.geterrobj()[1]
@@ -441,7 +449,7 @@ def setbufsize(size):
old = pyvals[:]
pyvals[0] = size
umath.seterrobj(pyvals)
- return old
+ return ufunc_values_obj(old)
def getbufsize():
return umath.geterrobj()[0]
@@ -453,7 +461,7 @@ def seterrcall(func):
old = pyvals[:]
pyvals[2] = func
umath.seterrobj(pyvals)
- return old
+ return ufunc_values_obj(old)
def geterrcall():
return umath.geterrobj()[2]