Skip to content

Commit e3b5e4c

Browse files
DOC: Use npf instead of nf in the docstring examples.
1 parent 08a6f8d commit e3b5e4c

File tree

1 file changed

+26
-26
lines changed

1 file changed

+26
-26
lines changed

numpy_financial/_financial.py

Lines changed: 26 additions & 26 deletions
Original file line numberDiff line numberDiff line change
@@ -112,13 +112,13 @@ def fv(rate, nper, pmt, pv, when='end'):
112112
Examples
113113
--------
114114
>>> import numpy as np
115-
>>> import numpy_financial as nf
115+
>>> import numpy_financial as npf
116116
117117
What is the future value after 10 years of saving $100 now, with
118118
an additional monthly savings of $100. Assume the interest rate is
119119
5% (annually) compounded monthly?
120120
121-
>>> nf.fv(0.05/12, 10*12, -100, -100)
121+
>>> npf.fv(0.05/12, 10*12, -100, -100)
122122
15692.928894335748
123123
124124
By convention, the negative sign represents cash flow out (i.e. money not
@@ -129,7 +129,7 @@ def fv(rate, nper, pmt, pv, when='end'):
129129
compare different interest rates from the example above.
130130
131131
>>> a = np.array((0.05, 0.06, 0.07))/12
132-
>>> nf.fv(a, 10*12, -100, -100)
132+
>>> npf.fv(a, 10*12, -100, -100)
133133
array([ 15692.92889434, 16569.87435405, 17509.44688102]) # may vary
134134
135135
"""
@@ -218,12 +218,12 @@ def pmt(rate, nper, pv, fv=0, when='end'):
218218
219219
Examples
220220
--------
221-
>>> import numpy_financial as nf
221+
>>> import numpy_financial as npf
222222
223223
What is the monthly payment needed to pay off a $200,000 loan in 15
224224
years at an annual interest rate of 7.5%?
225225
226-
>>> nf.pmt(0.075/12, 12*15, 200000)
226+
>>> npf.pmt(0.075/12, 12*15, 200000)
227227
-1854.0247200054619
228228
229229
In order to pay-off (i.e., have a future-value of 0) the $200,000 obtained
@@ -278,22 +278,22 @@ def nper(rate, pmt, pv, fv=0, when='end'):
278278
Examples
279279
--------
280280
>>> import numpy as np
281-
>>> import numpy_financial as nf
281+
>>> import numpy_financial as npf
282282
283283
If you only had $150/month to pay towards the loan, how long would it take
284284
to pay-off a loan of $8,000 at 7% annual interest?
285285
286-
>>> print(np.round(nf.nper(0.07/12, -150, 8000), 5))
286+
>>> print(np.round(npf.nper(0.07/12, -150, 8000), 5))
287287
64.07335
288288
289289
So, over 64 months would be required to pay off the loan.
290290
291291
The same analysis could be done with several different interest rates
292292
and/or payments and/or total amounts to produce an entire table.
293293
294-
>>> nf.nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
295-
... -150 : -99 : 50 ,
296-
... 8000 : 9001 : 1000]))
294+
>>> npf.nper(*(np.ogrid[0.07/12: 0.08/12: 0.01/12,
295+
... -150 : -99 : 50 ,
296+
... 8000 : 9001 : 1000]))
297297
array([[[ 64.07334877, 74.06368256],
298298
[108.07548412, 127.99022654]],
299299
[[ 66.12443902, 76.87897353],
@@ -365,7 +365,7 @@ def ipmt(rate, per, nper, pv, fv=0, when='end'):
365365
Examples
366366
--------
367367
>>> import numpy as np
368-
>>> import numpy_financial as nf
368+
>>> import numpy_financial as npf
369369
370370
What is the amortization schedule for a 1 year loan of $2500 at
371371
8.24% interest per year compounded monthly?
@@ -376,13 +376,13 @@ def ipmt(rate, per, nper, pv, fv=0, when='end'):
376376
financial equations start the period count at 1!
377377
378378
>>> per = np.arange(1*12) + 1
379-
>>> ipmt = nf.ipmt(0.0824/12, per, 1*12, principal)
380-
>>> ppmt = nf.ppmt(0.0824/12, per, 1*12, principal)
379+
>>> ipmt = npf.ipmt(0.0824/12, per, 1*12, principal)
380+
>>> ppmt = npf.ppmt(0.0824/12, per, 1*12, principal)
381381
382382
Each element of the sum of the 'ipmt' and 'ppmt' arrays should equal
383383
'pmt'.
384384
385-
>>> pmt = nf.pmt(0.0824/12, 1*12, principal)
385+
>>> pmt = npf.pmt(0.0824/12, 1*12, principal)
386386
>>> np.allclose(ipmt + ppmt, pmt)
387387
True
388388
@@ -533,14 +533,14 @@ def pv(rate, nper, pmt, fv=0, when='end'):
533533
Examples
534534
--------
535535
>>> import numpy as np
536-
>>> import numpy_financial as nf
536+
>>> import numpy_financial as npf
537537
538538
What is the present value (e.g., the initial investment)
539539
of an investment that needs to total $15692.93
540540
after 10 years of saving $100 every month? Assume the
541541
interest rate is 5% (annually) compounded monthly.
542542
543-
>>> nf.pv(0.05/12, 10*12, -100, 15692.93)
543+
>>> npf.pv(0.05/12, 10*12, -100, 15692.93)
544544
-100.00067131625819
545545
546546
By convention, the negative sign represents cash flow out
@@ -552,7 +552,7 @@ def pv(rate, nper, pmt, fv=0, when='end'):
552552
Let's compare different interest rates in the example above:
553553
554554
>>> a = np.array((0.05, 0.04, 0.03))/12
555-
>>> nf.pv(a, 10*12, -100, 15692.93)
555+
>>> npf.pv(a, 10*12, -100, 15692.93)
556556
array([ -100.00067132, -649.26771385, -1273.78633713]) # may vary
557557
558558
So, to end up with the same $15692.93 under the same $100 per month
@@ -718,17 +718,17 @@ def irr(values):
718718
719719
Examples
720720
--------
721-
>>> import numpy_financial as nf
721+
>>> import numpy_financial as npf
722722
723-
>>> round(nf.irr([-100, 39, 59, 55, 20]), 5)
723+
>>> round(npf.irr([-100, 39, 59, 55, 20]), 5)
724724
0.28095
725-
>>> round(nf.irr([-100, 0, 0, 74]), 5)
725+
>>> round(npf.irr([-100, 0, 0, 74]), 5)
726726
-0.0955
727-
>>> round(nf.irr([-100, 100, 0, -7]), 5)
727+
>>> round(npf.irr([-100, 100, 0, -7]), 5)
728728
-0.0833
729-
>>> round(nf.irr([-100, 100, 0, 7]), 5)
729+
>>> round(npf.irr([-100, 100, 0, 7]), 5)
730730
0.06206
731-
>>> round(nf.irr([-5, 10.5, 1, -8, 1]), 5)
731+
>>> round(npf.irr([-5, 10.5, 1, -8, 1]), 5)
732732
0.0886
733733
734734
"""
@@ -800,15 +800,15 @@ def npv(rate, values):
800800
Examples
801801
--------
802802
>>> import numpy as np
803-
>>> import numpy_financial as nf
803+
>>> import numpy_financial as npf
804804
805805
Consider a potential project with an initial investment of $40 000 and
806806
projected cashflows of $5 000, $8 000, $12 000 and $30 000 at the end of
807807
each period discounted at a rate of 8% per period. To find the project's
808808
net present value:
809809
810810
>>> rate, cashflows = 0.08, [-40_000, 5_000, 8_000, 12_000, 30_000]
811-
>>> nf.npv(rate, cashflows).round(5)
811+
>>> npf.npv(rate, cashflows).round(5)
812812
3065.22267
813813
814814
It may be preferable to split the projected cashflow into an initial
@@ -818,7 +818,7 @@ def npv(rate, values):
818818
819819
>>> initial_cashflow = cashflows[0]
820820
>>> cashflows[0] = 0
821-
>>> np.round(nf.npv(rate, cashflows) + initial_cashflow, 5)
821+
>>> np.round(npf.npv(rate, cashflows) + initial_cashflow, 5)
822822
3065.22267
823823
824824
"""

0 commit comments

Comments
 (0)