Skip to content

Commit b126521

Browse files
committed
MAINT: Refactor output array shape creation into own function
1 parent 4d329ac commit b126521

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

numpy_financial/_financial.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,10 @@ def _to_decimal_array_2d(array):
7373
return np.array(decimals).reshape(array.shape)
7474

7575

76+
def _get_output_array_shape(*arrays):
77+
return tuple(array.shape[0] for array in arrays)
78+
79+
7680
def fv(rate, nper, pmt, pv, when='end'):
7781
"""Compute the future value.
7882
@@ -970,7 +974,7 @@ def npv(rate, values):
970974
zero = dtype("0.0")
971975
one = dtype("1.0")
972976

973-
shape = tuple(array.shape[0] for array in (rates, values))
977+
shape = _get_output_array_shape(rates, values)
974978
out = np.empty(shape=shape, dtype=dtype)
975979

976980
if dtype == Decimal:

0 commit comments

Comments
 (0)