-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
BUG: fix+test assigning invalid NAT-like to DTA/TDA/PA #27331
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
expected = type(array)._from_sequence([pd.NaT, array[1], array[2]]) | ||
|
||
casting_nats = { | ||
TimedeltaArray: [pd.NaT, np.timedelta64("NaT", "ns")], |
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 too complicated, just provide the expected alongside the values above
DatetimeArray: [pd.NaT, np.datetime64("NaT", "ns")], | ||
PeriodArray: [pd.NaT], | ||
}[type(array)] | ||
non_casting_nats = { |
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 would be better to parameterize over the non_casting_nats and the casting_nats in a separate test. too much going on here.
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.
changed
@@ -651,3 +651,38 @@ def test_array_interface(self, period_index): | |||
result = np.asarray(arr, dtype="S20") | |||
expected = np.asarray(arr).astype("S20") | |||
tm.assert_numpy_array_equal(result, expected) | |||
|
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.
are there other setitem tests? put near those
], | ||
ids=lambda x: type(x).__name__, | ||
) | ||
def test_nat_assignment_array(array): |
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.
assignment -> setitem
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.
changed
comments addressed i think |
def test_casting_nat_setitem_array(array, casting_nats): | ||
expected = type(array)._from_sequence([pd.NaT, array[1], array[2]]) | ||
|
||
for nat in casting_nats: |
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 make another level of parameterization to make these truly separate tests?
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 don't think so; the casting_nats
parameter depends on the array
parameter.
I've been looking at pytest extensions that might make this kind of thing possible
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.
small comment, but followup ok
@@ -559,3 +559,27 @@ def remove_na_arraylike(arr): | |||
return arr[notna(arr)] | |||
else: | |||
return arr[notna(lib.values_from_object(arr))] | |||
|
|||
|
|||
def is_valid_nat_for_dtype(obj, dtype): |
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 type these(followup ok)
Broken off from #27311 for cleaner scope and to troubleshoot platform-specific failures. Related but orthogonal to #27323.