@@ -146,7 +146,7 @@ def fv(rate, nper, pmt, pv, when='end'):
146
146
5% (annually) compounded monthly?
147
147
148
148
>>> npf.fv(0.05/12, 10*12, -100, -100)
149
- 15692.928894335748
149
+ 15692.92889433575
150
150
151
151
By convention, the negative sign represents cash flow out (i.e. money not
152
152
available today). Thus, saving $100 a month at 5% annual interest leads
@@ -157,7 +157,7 @@ def fv(rate, nper, pmt, pv, when='end'):
157
157
158
158
>>> a = np.array((0.05, 0.06, 0.07))/12
159
159
>>> npf.fv(a, 10*12, -100, -100)
160
- array([ 15692.92889434, 16569.87435405, 17509.44688102]) # may vary
160
+ array([15692.92889434, 16569.87435405, 17509.44688102])
161
161
162
162
"""
163
163
when = _convert_when (when )
@@ -327,9 +327,9 @@ def nper(rate, pmt, pv, fv=0, when='end'):
327
327
... 8000 : 9001 : 1000]))
328
328
array([[[ 64.07334877, 74.06368256],
329
329
[108.07548412, 127.99022654]],
330
+ <BLANKLINE>
330
331
[[ 66.12443902, 76.87897353],
331
332
[114.70165583, 137.90124779]]])
332
-
333
333
"""
334
334
when = _convert_when (when )
335
335
rate , pmt , pv , fv , when = np .broadcast_arrays (rate , pmt , pv , fv , when )
@@ -592,7 +592,7 @@ def pv(rate, nper, pmt, fv=0, when='end'):
592
592
593
593
>>> a = np.array((0.05, 0.04, 0.03))/12
594
594
>>> npf.pv(a, 10*12, -100, 15692.93)
595
- array([ -100.00067132, -649.26771385, -1273.78633713]) # may vary
595
+ array([ -100.00067132, -649.26771385, -1273.78633713])
596
596
597
597
So, to end up with the same $15692.93 under the same $100 per month
598
598
"savings plan," for annual interest rates of 4% and 3%, one would
@@ -931,7 +931,7 @@ def npv(rate, values):
931
931
net present value:
932
932
933
933
>>> rate, cashflows = 0.08, [-40_000, 5_000, 8_000, 12_000, 30_000]
934
- >>> npf.npv(rate, cashflows).round( 5)
934
+ >>> np.round( npf.npv(rate, cashflows), 5)
935
935
3065.22267
936
936
937
937
It may be preferable to split the projected cashflow into an initial
@@ -1061,10 +1061,15 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
1061
1061
Finally, let's explore the situation where all cash flows are positive,
1062
1062
and the `raise_exceptions` parameter is set to True.
1063
1063
1064
- >>> npf.mirr([100, 50, 60, 70], 0.10, 0.12, raise_exceptions=True)
1065
- NoRealSolutionError: No real solution exists for MIRR since all
1066
- cashflows are of the same sign.
1067
-
1064
+ >>> npf.mirr([
1065
+ ... 100, 50, 60, 70],
1066
+ ... 0.10, 0.12,
1067
+ ... raise_exceptions=True
1068
+ ... ) #doctest: +NORMALIZE_WHITESPACE
1069
+ Traceback (most recent call last):
1070
+ ...
1071
+ numpy_financial._financial.NoRealSolutionError:
1072
+ No real solution exists for MIRR since all cashflows are of the same sign.
1068
1073
"""
1069
1074
values = np .asarray (values )
1070
1075
n = values .size
0 commit comments