Skip to content

Commit 29978ca

Browse files
committed
Small modification to irr function. When all the cashflows are of the same sign and thus it returns np.nans, it prints a message, to make it more user intuitive
1 parent fb63b04 commit 29978ca

File tree

1 file changed

+3
-0
lines changed

1 file changed

+3
-0
lines changed

numpy_financial/_financial.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -753,6 +753,9 @@ def irr(values, guess=None, tol=1e-12, maxiter=100):
753753
# we don't perform any further calculations and exit early
754754
same_sign = np.all(values > 0) if values[0] > 0 else np.all(values < 0)
755755
if same_sign:
756+
print('No solution exists for IRR since all'
757+
'cashflows are of the same sign. Returning'
758+
'np.nan')
756759
return np.nan
757760

758761
# If no value is passed for `guess`, then make a heuristic estimate

0 commit comments

Comments
 (0)