diff options
author | Tim Hochberg <tim_hochberg@local> | 2006-10-19 18:26:00 +0000 |
---|---|---|
committer | Tim Hochberg <tim_hochberg@local> | 2006-10-19 18:26:00 +0000 |
commit | 0d9589d534383c8e4291d0579208b36ece2312e1 (patch) | |
tree | 38a3c2c355108281482b42be1d061fca0ad6974c /numpy/core/numeric.py | |
parent | c08e80eb6c1f47a9d65e363316ae1f6c6e6f870d (diff) | |
download | numpy-0d9589d534383c8e4291d0579208b36ece2312e1.tar.gz |
Added tests for errstate(call=x). Made minor change to errstate so that an existing call can be suppressed using None during a block as well replaced.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r-- | numpy/core/numeric.py | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index c5a108e43..84329edbc 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -753,6 +753,10 @@ def geterrcall(): """ return umath.geterrobj()[2] +class _unspecified(object): + pass +_Unspecified = _unspecified() + class errstate(object): """with errstate(**state): --> operations in following block use given state. @@ -781,15 +785,15 @@ class errstate(object): # Note that we don't want to run the above doctests because they will fail # without a from __future__ import with_statement def __init__(self, **kwargs): - self.call = kwargs.pop('call',None) + self.call = kwargs.pop('call',_Unspecified) self.kwargs = kwargs def __enter__(self): self.oldstate = seterr(**self.kwargs) - if self.call: + if self.call is not _Unspecified: self.oldcall = seterrcall(self.call) def __exit__(self, *exc_info): seterr(**self.oldstate) - if self.call: + if self.call is not _Unspecified: seterrcall(self.oldcall) def _setdef(): |