diff options
| author | Charles Harris <charlesr.harris@gmail.com> | 2013-07-11 17:16:42 -0700 |
|---|---|---|
| committer | Charles Harris <charlesr.harris@gmail.com> | 2013-07-11 17:16:42 -0700 |
| commit | a053a4372aba0af0bd63ffd5e207baf469cfc7bf (patch) | |
| tree | afcdad0da5b29ce832528474246dcb66bc1491cf /numpy/lib/financial.py | |
| parent | e1c4806b649933383fb610205fb612c438360472 (diff) | |
| parent | 2f1174dee44e901b7d028beb86f4a8ea324bd74f (diff) | |
| download | numpy-a053a4372aba0af0bd63ffd5e207baf469cfc7bf.tar.gz | |
Merge pull request #3518 from charris/use-errstate-context-manager
MAINT: Use np.errstate context manager.
Diffstat (limited to 'numpy/lib/financial.py')
| -rw-r--r-- | numpy/lib/financial.py | 5 |
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) |
