Skip to content

Commit 6561c6d

Browse files
committed
ENH: NPV: Move private array conversion functions to top of file
1 parent f1c2e54 commit 6561c6d

File tree

1 file changed

+9
-9
lines changed

1 file changed

+9
-9
lines changed

numpy_financial/_financial.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ def _use_decimal_dtype(*arrays):
6363
return any(_is_object_array(array) for array in arrays)
6464

6565

66+
def _to_decimal_array_1d(array):
67+
return np.array([Decimal(x) for x in array.tolist()])
68+
69+
70+
def _to_decimal_array_2d(array):
71+
decimals = [Decimal(x) for row in array.tolist() for x in row]
72+
return np.array(decimals).reshape(array.shape)
73+
74+
6675
def fv(rate, nper, pmt, pv, when='end'):
6776
"""Compute the future value.
6877
@@ -842,15 +851,6 @@ def irr(values, *, guess=None, tol=1e-12, maxiter=100, raise_exceptions=False):
842851
return np.nan
843852

844853

845-
def _to_decimal_array_1d(array):
846-
return np.array([Decimal(x) for x in array.tolist()])
847-
848-
849-
def _to_decimal_array_2d(array):
850-
l = [Decimal(x) for row in array.tolist() for x in row]
851-
return np.array(l).reshape(array.shape)
852-
853-
854854
def npv(rate, values):
855855
r"""Return the NPV (Net Present Value) of a cash flow series.
856856

0 commit comments

Comments
 (0)