diff options
author | naveenarun <notatroll.troll@gmail.com> | 2016-09-21 23:31:51 -0500 |
---|---|---|
committer | Alec Hodgkinson <Hodgka@rpi.edu> | 2016-09-23 19:04:14 -0400 |
commit | 36f88442209e74f0fcb63ec2aa3868b63f7dafb4 (patch) | |
tree | 5ef36cbbf8614ee2b0723423c8ab1dd30c41bdd5 /numpy | |
parent | 04a9eac54dff8f74d6433b25c3cb722ccd98b077 (diff) | |
download | numpy-36f88442209e74f0fcb63ec2aa3868b63f7dafb4.tar.gz |
BUG: financial.pmt modifies input #8055
financial.pmt masked rate array in place, changing rate array.
Changed to mask to a new array, preserving the original rate array.
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/lib/financial.py | 7 | ||||
-rw-r--r-- | numpy/testing/utils.py | 2 |
2 files changed, 5 insertions, 4 deletions
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py index 931b0af56..95942da16 100644 --- a/numpy/lib/financial.py +++ b/numpy/lib/financial.py @@ -210,9 +210,10 @@ def pmt(rate, nper, pv, fv=0, when='end'): (rate, nper, pv, fv, when) = map(np.array, [rate, nper, pv, fv, when]) temp = (1 + rate)**nper mask = (rate == 0.0) - np.copyto(rate, 1.0, where=mask) - z = np.zeros(np.broadcast(rate, nper, pv, fv, when).shape) - fact = np.where(mask != z, nper + z, (1 + rate*when)*(temp - 1)/rate + z) + masked_rate = np.where(mask, 1.0, rate) + z = np.zeros(np.broadcast(masked_rate, nper, pv, fv, when).shape) + fact = np.where(mask != z, nper + z, + (1 + masked_rate*when)*(temp - 1)/masked_rate + z) return -(fv + pv*temp) / fact def nper(rate, pmt, pv, fv=0, when='end'): diff --git a/numpy/testing/utils.py b/numpy/testing/utils.py index 683a4f0a6..cb39a9b4a 100644 --- a/numpy/testing/utils.py +++ b/numpy/testing/utils.py @@ -64,7 +64,7 @@ def import_nose(): if not nose_is_good: msg = ('Need nose >= %d.%d.%d for tests - see ' - 'http://somethingaboutorange.com/mrl/projects/nose' % + 'http://nose.readthedocs.io' % minimum_nose_version) raise ImportError(msg) |