summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
authorCharles Harris <charlesr.harris@gmail.com>2016-09-23 18:58:55 -0500
committerGitHub <noreply@github.com>2016-09-23 18:58:55 -0500
commita6574b2f080e4050e4b091fd3fa71be1f377f895 (patch)
treea8aa1853c17abb9f757c50561a81a1d3ae60ea29 /numpy/lib
parentc6185dd350854cd5fc98cbc42e648b57bc670a60 (diff)
parent36f88442209e74f0fcb63ec2aa3868b63f7dafb4 (diff)
downloadnumpy-a6574b2f080e4050e4b091fd3fa71be1f377f895.tar.gz
Merge pull request #8087 from hodgka/master
BUG: financial.pmt modifies input #8055
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'):