-
-
Notifications
You must be signed in to change notification settings - Fork 9.7k
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
ENH: Add datatime64 support in np.interp #14990
base: main
Are you sure you want to change the base?
Conversation
For other's reviewing - previously this raised |
yp = np.array([1, 3]) | ||
x = np.datetime64('2019-01-02') | ||
assert_equal(np.interp(x, xp, yp), 2.) | ||
assert_raises(TypeError, np.interp(1., xp, yp)) |
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.
I was expecting this test to fail, but it seems to pass.. Any idea which line of your code causes the TypeError
?
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.
It should fail.
np.interp(1., xp, yp)
doesn't raise this error. It might be a problem with assert_raises and it's similar to #15008
But do we want to check if types in x and xp are the same? Maybe it's enough that both can be cast to np.float64
?
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.
My bad, it should have been
assert_raises(TypeError, np.interp, 1., xp, yp)
But again, is this a better approach?
This PR would make np.interp support any type that can be converter to float64. In my opinion that's a better approach. Happy to receive any feedback.. |
ENH: Add support for types convertible to float64 in np.interp
Closes #14941