summaryrefslogtreecommitdiff
path: root/numpy/lib
diff options
context:
space:
mode:
Diffstat (limited to 'numpy/lib')
-rw-r--r--numpy/lib/financial.py10
-rw-r--r--numpy/lib/tests/test_financial.py2
2 files changed, 6 insertions, 6 deletions
diff --git a/numpy/lib/financial.py b/numpy/lib/financial.py
index 496e960fc..5d1e65f5c 100644
--- a/numpy/lib/financial.py
+++ b/numpy/lib/financial.py
@@ -625,17 +625,17 @@ def mirr(values, finance_rate, reinvest_rate):
"""
- values = np.asarray(values)
+ values = np.asarray(values, dtype=np.double)
initial = values[0]
values = values[1:]
n = values.size
pos = values > 0
neg = values < 0
- if not (pos.sum() > 0 and neg.sum() > 0):
+ if not (pos.any() and neg.any()):
return np.nan
numer = np.abs(npv(reinvest_rate, values*pos))
denom = np.abs(npv(finance_rate, values*neg))
- if initial > 0:
- return ((initial + numer) / denom)**(1.0/n)*(1+reinvest_rate) - 1
+ if initial > 0:
+ return ((initial + numer) / denom)**(1.0/n)*(1 + reinvest_rate) - 1
else:
- return ((numer / (-initial + denom)))**(1.0/n)*(1+reinvest_rate) - 1
+ return ((numer / (-initial + denom)))**(1.0/n)*(1 + reinvest_rate) - 1
diff --git a/numpy/lib/tests/test_financial.py b/numpy/lib/tests/test_financial.py
index 0ad3766bf..3c9703621 100644
--- a/numpy/lib/tests/test_financial.py
+++ b/numpy/lib/tests/test_financial.py
@@ -43,7 +43,7 @@ class TestFinancial(TestCase):
v2 = [-120000,39000,30000,21000,37000,46000]
assert_almost_equal(np.mirr(v2,0.10,0.12),
0.1344, 4)
-
+
v3 = [100,200,-50,300,-200]
assert_almost_equal(np.mirr(v3,0.05,0.06), 0.3428, 4)