-
-
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
Changes from all commits
4a862dd
74a4254
24db8a7
20eca07
a81b9ad
3137cfb
d55c508
2281749
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -651,3 +651,51 @@ 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 commentThe reason will be displayed to describe this comment to others. Learn more. are there other setitem tests? put near those |
||
|
||
@pytest.mark.parametrize( | ||
"array,casting_nats", | ||
[ | ||
( | ||
pd.TimedeltaIndex(["1 Day", "3 Hours", "NaT"])._data, | ||
(pd.NaT, np.timedelta64("NaT", "ns")), | ||
), | ||
( | ||
pd.date_range("2000-01-01", periods=3, freq="D")._data, | ||
(pd.NaT, np.datetime64("NaT", "ns")), | ||
), | ||
(pd.period_range("2000-01-01", periods=3, freq="D")._data, (pd.NaT,)), | ||
], | ||
ids=lambda x: type(x).__name__, | ||
) | ||
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 commentThe 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 commentThe reason will be displayed to describe this comment to others. Learn more. I don't think so; the I've been looking at pytest extensions that might make this kind of thing possible |
||
arr = array.copy() | ||
arr[0] = nat | ||
tm.assert_equal(arr, expected) | ||
|
||
|
||
@pytest.mark.parametrize( | ||
"array,non_casting_nats", | ||
[ | ||
( | ||
pd.TimedeltaIndex(["1 Day", "3 Hours", "NaT"])._data, | ||
(np.datetime64("NaT", "ns"),), | ||
), | ||
( | ||
pd.date_range("2000-01-01", periods=3, freq="D")._data, | ||
(np.timedelta64("NaT", "ns"),), | ||
), | ||
( | ||
pd.period_range("2000-01-01", periods=3, freq="D")._data, | ||
(np.datetime64("NaT", "ns"), np.timedelta64("NaT", "ns")), | ||
), | ||
], | ||
ids=lambda x: type(x).__name__, | ||
) | ||
def test_invalid_nat_setitem_array(array, non_casting_nats): | ||
for nat in non_casting_nats: | ||
with pytest.raises(TypeError): | ||
array[0] = nat |
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)