summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authornaveenarun <notatroll.troll@gmail.com>2016-09-21 23:31:51 -0500
committerAlec Hodgkinson <Hodgka@rpi.edu>2016-09-23 19:04:14 -0400
commit36f88442209e74f0fcb63ec2aa3868b63f7dafb4 (patch)
tree5ef36cbbf8614ee2b0723423c8ab1dd30c41bdd5 /numpy/lib
parent04a9eac54dff8f74d6433b25c3cb722ccd98b077 (diff)
downloadnumpy-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/lib')
-rw-r--r--numpy/lib/financial.py7
1 files changed, 4 insertions, 3 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'):