@@ -756,7 +756,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
756756 User may insert their own customised function for selection
757757 of IRR values.The function should accept a one-dimensional array
758758 of numbers and return a number.
759-
759+
760760
761761 Returns
762762 -------
@@ -803,7 +803,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
803803 0.0886
804804 >>> npf.irr([[-100, 0, 0, 74], [-100, 100, 0, 7]]).round(5)
805805 array([-0.0955 , 0.06206])
806-
806+
807807 """
808808 values = np .atleast_2d (values )
809809 if values .ndim != 2 :
@@ -852,7 +852,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
852852 # If only one real solution
853853 elif len (eirr ) == 1 :
854854 irr_results [i ] = eirr [0 ]
855- else :
855+ else :
856856 irr_results [i ] = selection_logic (eirr )
857857
858858 return _ufunc_like (irr_results )
@@ -986,7 +986,7 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
986986
987987 .. math::
988988
989- MIRR =
989+ MIRR =
990990 \\left( \\frac{{FV_{positive}}}{{PV_{negative}}} \\right)^{\\frac{{1}}{{n-1}}}
991991 * (1+r) - 1
992992
@@ -1000,8 +1000,8 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10001000 --------
10011001 >>> import numpy_financial as npf
10021002
1003- Consider a project with an initial investment of -$100
1004- and projected cash flows of $50, -$60, and $70 at the end of each period.
1003+ Consider a project with an initial investment of -$100
1004+ and projected cash flows of $50, -$60, and $70 at the end of each period.
10051005 The project has a finance rate of 10% and a reinvestment rate of 12%.
10061006
10071007 >>> npf.mirr([-100, 50, -60, 70], 0.10, 0.12)
@@ -1028,17 +1028,17 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10281028 >>> npf.mirr([-100, -50, -60, -70], 0.10, 0.12)
10291029 nan
10301030
1031- Finally, let's explore the situation where all cash flows are positive,
1031+ Finally, let's explore the situation where all cash flows are positive,
10321032 and the `raise_exceptions` parameter is set to True.
10331033
10341034 >>> npf.mirr([
1035- ... 100, 50, 60, 70],
1036- ... 0.10, 0.12,
1035+ ... 100, 50, 60, 70],
1036+ ... 0.10, 0.12,
10371037 ... raise_exceptions=True
10381038 ... ) #doctest: +NORMALIZE_WHITESPACE
10391039 Traceback (most recent call last):
10401040 ...
1041- numpy_financial._financial.NoRealSolutionError:
1041+ numpy_financial._financial.NoRealSolutionError:
10421042 No real solution exists for MIRR since all cashflows are of the same sign.
10431043 """
10441044 values_inner = np .atleast_2d (values ).astype (np .float64 )
@@ -1055,7 +1055,9 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
10551055 out = np .empty (out_shape )
10561056
10571057 for i , v in enumerate (values_inner ):
1058- for j , (rr , fr ) in enumerate (zip (reinvest_rate_inner , finance_rate_inner )):
1058+ for j , (rr , fr ) in enumerate (
1059+ zip (reinvest_rate_inner , finance_rate_inner , strict = True )
1060+ ):
10591061 pos = v > 0
10601062 neg = v < 0
10611063
0 commit comments