Skip to content

Commit da251b0

Browse files
MAINT: Remove array dispatch wrappers.
1 parent b922ece commit da251b0

File tree

1 file changed

+0
-57
lines changed

1 file changed

+0
-57
lines changed

numpy_financial/_financial.py

Lines changed: 0 additions & 57 deletions
Original file line numberDiff line numberDiff line change
@@ -13,14 +13,8 @@
1313
from __future__ import division, absolute_import, print_function
1414

1515
from decimal import Decimal
16-
import functools
1716

1817
import numpy as np
19-
from numpy.core import overrides
20-
21-
22-
array_function_dispatch = functools.partial(
23-
overrides.array_function_dispatch, module='numpy')
2418

2519

2620
__all__ = ['fv', 'pmt', 'nper', 'ipmt', 'ppmt', 'pv', 'rate',
@@ -45,11 +39,6 @@ def _convert_when(when):
4539
return [_when_to_num[x] for x in when]
4640

4741

48-
def _fv_dispatcher(rate, nper, pmt, pv, when=None):
49-
return (rate, nper, pmt, pv)
50-
51-
52-
@array_function_dispatch(_fv_dispatcher)
5342
def fv(rate, nper, pmt, pv, when='end'):
5443
"""
5544
Compute the future value.
@@ -142,11 +131,6 @@ def fv(rate, nper, pmt, pv, when='end'):
142131
return -(pv*temp + pmt*fact)
143132

144133

145-
def _pmt_dispatcher(rate, nper, pv, fv=None, when=None):
146-
return (rate, nper, pv, fv)
147-
148-
149-
@array_function_dispatch(_pmt_dispatcher)
150134
def pmt(rate, nper, pv, fv=0, when='end'):
151135
"""
152136
Compute the payment against loan principal plus interest.
@@ -242,11 +226,6 @@ def pmt(rate, nper, pv, fv=0, when='end'):
242226
return -(fv + pv*temp) / fact
243227

244228

245-
def _nper_dispatcher(rate, pmt, pv, fv=None, when=None):
246-
return (rate, pmt, pv, fv)
247-
248-
249-
@array_function_dispatch(_nper_dispatcher)
250229
def nper(rate, pmt, pv, fv=0, when='end'):
251230
"""
252231
Compute the number of periodic payments.
@@ -319,11 +298,6 @@ def nper(rate, pmt, pv, fv=0, when='end'):
319298
return np.where(rate == 0, A, B)
320299

321300

322-
def _ipmt_dispatcher(rate, per, nper, pv, fv=None, when=None):
323-
return (rate, per, nper, pv, fv)
324-
325-
326-
@array_function_dispatch(_ipmt_dispatcher)
327301
def ipmt(rate, per, nper, pv, fv=0, when='end'):
328302
"""
329303
Compute the interest portion of a payment.
@@ -433,11 +407,6 @@ def _rbl(rate, per, pmt, pv, when):
433407
return fv(rate, (per - 1), pmt, pv, when)
434408

435409

436-
def _ppmt_dispatcher(rate, per, nper, pv, fv=None, when=None):
437-
return (rate, per, nper, pv, fv)
438-
439-
440-
@array_function_dispatch(_ppmt_dispatcher)
441410
def ppmt(rate, per, nper, pv, fv=0, when='end'):
442411
"""
443412
Compute the payment against loan principal.
@@ -467,11 +436,6 @@ def ppmt(rate, per, nper, pv, fv=0, when='end'):
467436
return total - ipmt(rate, per, nper, pv, fv, when)
468437

469438

470-
def _pv_dispatcher(rate, nper, pmt, fv=None, when=None):
471-
return (rate, nper, nper, pv, fv)
472-
473-
474-
@array_function_dispatch(_pv_dispatcher)
475439
def pv(rate, nper, pmt, fv=0, when='end'):
476440
"""
477441
Compute the present value.
@@ -586,19 +550,13 @@ def _g_div_gp(r, n, p, x, y, w):
586550
return g / gp
587551

588552

589-
def _rate_dispatcher(nper, pmt, pv, fv, when=None, guess=None, tol=None,
590-
maxiter=None):
591-
return (nper, pmt, pv, fv)
592-
593-
594553
# Use Newton's iteration until the change is less than 1e-6
595554
# for all values or a maximum of 100 iterations is reached.
596555
# Newton's rule is
597556
# r_{n+1} = r_{n} - g(r_n)/g'(r_n)
598557
# where
599558
# g(r) is the formula
600559
# g'(r) is the derivative with respect to r.
601-
@array_function_dispatch(_rate_dispatcher)
602560
def rate(nper, pmt, pv, fv, when='end', guess=None, tol=None, maxiter=100):
603561
"""
604562
Compute the rate of interest per period.
@@ -671,11 +629,6 @@ def rate(nper, pmt, pv, fv, when='end', guess=None, tol=None, maxiter=100):
671629
return rn
672630

673631

674-
def _irr_dispatcher(values):
675-
return (values,)
676-
677-
678-
@array_function_dispatch(_irr_dispatcher)
679632
def irr(values):
680633
"""
681634
Return the Internal Rate of Return (IRR).
@@ -756,11 +709,6 @@ def irr(values):
756709
return rate
757710

758711

759-
def _npv_dispatcher(rate, values):
760-
return (values,)
761-
762-
763-
@array_function_dispatch(_npv_dispatcher)
764712
def npv(rate, values):
765713
"""
766714
Returns the NPV (Net Present Value) of a cash flow series.
@@ -833,11 +781,6 @@ def npv(rate, values):
833781
return (values / (1+rate)**np.arange(0, len(values))).sum(axis=0)
834782

835783

836-
def _mirr_dispatcher(values, finance_rate, reinvest_rate):
837-
return (values,)
838-
839-
840-
@array_function_dispatch(_mirr_dispatcher)
841784
def mirr(values, finance_rate, reinvest_rate):
842785
"""
843786
Modified internal rate of return.

0 commit comments

Comments
 (0)