-
-
Notifications
You must be signed in to change notification settings - Fork 87
Description
Hello,
Today I noticed that where a list of present values and a list of future values are used as input to npf.rate()
, each element in the list returned is nan
if only just one present/future value combination exhibits the same sign. Is this behavior intentional? I would have expected only that particular problematic pair to have returned nan
, as the other pairs' results remain valid and calculable.
As you can see by the reproducible example below, all you need to do to resolve this case is drop the last element from each list and the preceding elements (all of which exhibit opposing signs) calculate as expected. Leave the last elements in place, and you get back a list of all nan
.
Thanks!
-Tyler
import numpy_financial as npf
pv = [-593.06, -4725.38, -662.05, -428.78, -13.65]
fv = [214.07, 4509.97, 224.11, 686.29, -329.67]
print(npf.rate(2, 0, pv, fv))
[nan nan nan nan nan]
print(npf.rate(2, 0, pv[0:-1], fv[0:-1]))
[-0.39920185 -0.02305873 -0.41818459 0.26513414]