Skip to content

Commit f58c8df

Browse files
committed
DOC: NPV: Document new "broadcasting" behaviour
1 parent 8c723d2 commit f58c8df

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

numpy_financial/_financial.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -862,6 +862,7 @@ def _npv_native(rates, values, out, zero, one):
862862
out[i, j] = acc
863863

864864

865+
# We require ``forceobj=True`` here to support decimal.Decimal types
865866
@nb.jit(forceobj=True)
866867
def _npv_decimal(rates, values, out, zero, one):
867868
for i in range(rates.shape[0]):
@@ -938,6 +939,17 @@ def npv(rate, values):
938939
>>> np.round(npf.npv(rate, cashflows) + initial_cashflow, 5)
939940
3065.22267
940941
942+
The NPV calculation may be applied to several ``rates`` and ``cashflows``
943+
simulatneously. This produces an array of shape
944+
``(len(rates), len(cashflows))``.
945+
946+
>>> rates = [0.00, 0.05, 0.10]
947+
>>> cashflows = [[-4_000, 500, 800], [-5_000, 600, 900]]
948+
>>> npf.npv(rates, cashflows).round(2)
949+
array([[-2700. , -3500. ],
950+
[-2798.19, -3612.24],
951+
[-2884.3 , -3710.74]])
952+
941953
"""
942954
rates = np.atleast_1d(rate)
943955
values = np.atleast_2d(values)

0 commit comments

Comments
 (0)