summaryrefslogtreecommitdiff
path: root/numpy/lib/financial.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/lib/financial.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/lib/financial.py')
-rw-r--r--numpy/lib/financial.py5
1 files changed, 1 insertions, 4 deletions
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py
index 0be12f2c7..8cac117c9 100644
--- a/numpy/lib/financial.py
+++ b/numpy/lib/financial.py
@@ -266,14 +266,11 @@ def nper(rate, pmt, pv, fv=0, when='end'):
(rate, pmt, pv, fv, when) = map(np.asarray, [rate, pmt, pv, fv, when])
use_zero_rate = False
- old_err = np.seterr(divide="raise")
- try:
+ with np.errstate(divide="raise"):
try:
z = pmt*(1.0+rate*when)/rate
except FloatingPointError:
use_zero_rate = True
- finally:
- np.seterr(**old_err)
if use_zero_rate:
return (-fv + pv) / (pmt + 0.0)