-
-
Notifications
You must be signed in to change notification settings - Fork 87
BUG: make ipmt
return nan
for per < 1
#22
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
As stated in the the docs the period count starts at 1, so `per < 1` doesn't make sense. The change also agrees with the results of Google Sheet's IPMT. Closes numpygh-17.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM 👍 - do you intend to add any further changes?
ipmt = np.where(np.logical_and(when == 1, per == 1), 0, ipmt) | ||
except IndexError: | ||
pass | ||
ipmt = np.array(_rbl(rate, per, total_pmt, pv, when) * rate) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and below the logic looks good to me. Having the extra comments is also appreciated. 👍
numpy_financial/_financial.py
Outdated
if isinstance(entry, Decimal): | ||
return Decimal(value) | ||
else: | ||
return value |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: should value here be case to the same dtype as entry?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good point; fixed.
Not here-was planning on refactoring the tests for |
Merged, thanks @person142! 👍 To the |
As stated in the the docs the period count starts at 1, so
per < 1
doesn't make sense. The change also agrees with the results of Google
Sheet's IPMT.
Closes gh-17. Note that the suggested fix there appears to be
incorrect-returning
0
forwhen = 'begin'
andper = 1
shouldbe the correct behavior as no interest has accrued at the beginning
of the first period. (Returning 0 also agrees with IPMT.)