From df5af393e98eb0ce91689966df698b6252b56776 Mon Sep 17 00:00:00 2001 From: Kai Striega Date: Sat, 6 Jul 2024 11:45:45 +1000 Subject: [PATCH] MAINT: Fix doctests for NumPy 2.0 --- numpy_financial/_financial.py | 12 ++++++------ 1 file changed, 6 insertions(+), 6 deletions(-) diff --git a/numpy_financial/_financial.py b/numpy_financial/_financial.py index c5cd231..dd6f35d 100644 --- a/numpy_financial/_financial.py +++ b/numpy_financial/_financial.py @@ -245,7 +245,7 @@ def pmt(rate, nper, pv, fv=0, when='end'): years at an annual interest rate of 7.5%? >>> npf.pmt(0.075/12, 12*15, 200000) - -1854.0247200054619 + np.float64(-1854.0247200054619) In order to pay-off (i.e., have a future-value of 0) the $200,000 obtained today, a monthly payment of $1,854.02 would be required. Note that this @@ -424,7 +424,7 @@ def ipmt(rate, per, nper, pv, fv=0, when='end'): >>> interestpd = np.sum(ipmt) >>> np.round(interestpd, 2) - -112.98 + np.float64(-112.98) """ when = _convert_when(when) @@ -562,7 +562,7 @@ def pv(rate, nper, pmt, fv=0, when='end'): interest rate is 5% (annually) compounded monthly. >>> npf.pv(0.05/12, 10*12, -100, 15692.93) - -100.00067131625819 + np.float64(-100.00067131625819) By convention, the negative sign represents cash flow out (i.e., money not available today). Thus, to end up with @@ -913,7 +913,7 @@ def npv(rate, values): >>> rate, cashflows = 0.08, [-40_000, 5_000, 8_000, 12_000, 30_000] >>> np.round(npf.npv(rate, cashflows), 5) - 3065.22267 + np.float64(3065.22267) It may be preferable to split the projected cashflow into an initial investment and expected future cashflows. In this case, the value of @@ -923,7 +923,7 @@ def npv(rate, values): >>> initial_cashflow = cashflows[0] >>> cashflows[0] = 0 >>> np.round(npf.npv(rate, cashflows) + initial_cashflow, 5) - 3065.22267 + np.float64(3065.22267) The NPV calculation may be applied to several ``rates`` and ``cashflows`` simulatneously. This produces an array of shape ``(len(rates), len(cashflows))``. @@ -1005,7 +1005,7 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False): The project has a finance rate of 10% and a reinvestment rate of 12%. >>> npf.mirr([-100, 50, -60, 70], 0.10, 0.12) - -0.03909366594356467 + np.float64(-0.03909366594356467) Now, let's consider the scenario where all cash flows are negative.