-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
TST: Add astype_nansafe datetime tests #28533
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
|
||
|
||
@pytest.mark.parametrize("from_type", [np.datetime64, np.timedelta64]) | ||
@pytest.mark.parametrize( |
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.
Could this get used elsewhere? If so might be good to make a shared fixture for numeric_dtype
or something to the effect
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.
This particular setup might be a little specific in that all the to_types
have lesser precision than the from_types
, but did you have something in mind?
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.
this is ok
|
||
|
||
@pytest.mark.parametrize("from_type", [np.datetime64, np.timedelta64]) | ||
@pytest.mark.parametrize( |
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.
this is ok
@pytest.mark.parametrize("from_type", [np.datetime64, np.timedelta64]) | ||
@pytest.mark.parametrize( | ||
"to_type", | ||
[ |
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.
can you add a test for the object path (for dtype=) when its a datetime/timedelta
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.
What would the expected output be for that case? I would think it'd agree with astype
from numpy
when we don't have any NA values but the result is a bit odd:
[ins] In [3]: arr = np.array([np.datetime64("2018")])
[ins] In [4]: arr.astype("object")
Out[4]: array([datetime.date(2018, 1, 1)], dtype=object)
[ins] In [5]: astype_nansafe(arr, dtype="object")
Out[5]: array([datetime.datetime(1970, 1, 1, 0, 0)], dtype=object)
how is this PR distinct from #28492 |
I was thinking it was worth treating separately since that PR deals with |
i would just close this and merge #28492 |
Adds tests for
astype_nansafe
in situations where we can't perform a datetime casting because of a precision mismatch:Related to #28492