@@ -756,7 +756,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
756
756
User may insert their own customised function for selection
757
757
of IRR values.The function should accept a one-dimensional array
758
758
of numbers and return a number.
759
-
759
+
760
760
761
761
Returns
762
762
-------
@@ -803,7 +803,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
803
803
0.0886
804
804
>>> npf.irr([[-100, 0, 0, 74], [-100, 100, 0, 7]]).round(5)
805
805
array([-0.0955 , 0.06206])
806
-
806
+
807
807
"""
808
808
values = np .atleast_2d (values )
809
809
if values .ndim != 2 :
@@ -852,7 +852,7 @@ def irr(values, *, raise_exceptions=False, selection_logic=_irr_default_selectio
852
852
# If only one real solution
853
853
elif len (eirr ) == 1 :
854
854
irr_results [i ] = eirr [0 ]
855
- else :
855
+ else :
856
856
irr_results [i ] = selection_logic (eirr )
857
857
858
858
return _ufunc_like (irr_results )
@@ -986,7 +986,7 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
986
986
987
987
.. math::
988
988
989
- MIRR =
989
+ MIRR =
990
990
\\left( \\frac{{FV_{positive}}}{{PV_{negative}}} \\right)^{\\frac{{1}}{{n-1}}}
991
991
* (1+r) - 1
992
992
@@ -1000,8 +1000,8 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
1000
1000
--------
1001
1001
>>> import numpy_financial as npf
1002
1002
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.
1005
1005
The project has a finance rate of 10% and a reinvestment rate of 12%.
1006
1006
1007
1007
>>> npf.mirr([-100, 50, -60, 70], 0.10, 0.12)
@@ -1028,17 +1028,17 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
1028
1028
>>> npf.mirr([-100, -50, -60, -70], 0.10, 0.12)
1029
1029
nan
1030
1030
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,
1032
1032
and the `raise_exceptions` parameter is set to True.
1033
1033
1034
1034
>>> npf.mirr([
1035
- ... 100, 50, 60, 70],
1036
- ... 0.10, 0.12,
1035
+ ... 100, 50, 60, 70],
1036
+ ... 0.10, 0.12,
1037
1037
... raise_exceptions=True
1038
1038
... ) #doctest: +NORMALIZE_WHITESPACE
1039
1039
Traceback (most recent call last):
1040
1040
...
1041
- numpy_financial._financial.NoRealSolutionError:
1041
+ numpy_financial._financial.NoRealSolutionError:
1042
1042
No real solution exists for MIRR since all cashflows are of the same sign.
1043
1043
"""
1044
1044
values_inner = np .atleast_2d (values ).astype (np .float64 )
@@ -1055,7 +1055,9 @@ def mirr(values, finance_rate, reinvest_rate, *, raise_exceptions=False):
1055
1055
out = np .empty (out_shape )
1056
1056
1057
1057
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
+ ):
1059
1061
pos = v > 0
1060
1062
neg = v < 0
1061
1063
0 commit comments