-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
Add simple test for GH 28448 #29269
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
Add simple test for GH 28448 #29269
Changes from 1 commit
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 |
---|---|---|
|
@@ -223,6 +223,28 @@ def test_cast_category_to_extension_dtype(self, expected): | |
|
||
tm.assert_series_equal(result, expected) | ||
|
||
@pytest.mark.parametrize( | ||
"data, dtype, expected", | ||
[ | ||
( | ||
"2015-01-01", | ||
"datetime64[ns]", | ||
np.array(["2015-01-01T00:00:00.000000000"], dtype="datetime64[ns]"), | ||
), | ||
( | ||
"2015-01-01", | ||
"datetime64[ns, MET]", | ||
np.array( | ||
[Timestamp("2015-01-01 00:00:00+0100", tz="MET")], dtype=object | ||
), | ||
), | ||
], | ||
) | ||
def test_consistent_casting(self, data, dtype, expected): | ||
# GH 28448 | ||
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. The OP uses 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. As in, In the first case (when 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. Hmm well I think that is a problem that as type would return a numpy array for "datetime64[ns]" and a DatetimeArray for "datetime64[ns, ]" but @jbrockmendel or @TomAugspurger might know more 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. Sorry, I don't totally follow the discussion but it seems like #28448 is about So I think the test should be something like result = pd.Categorical(data).astype(dtype)
tm.assert_equal(result, expected) no asarray. 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. Right I think so too. But the problem is That seems odd to me but I don't know the entire history of these 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. In theory 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. @WillAyd I tend to agree with everyone above in that this is sub-optimal behavior but not worth changing on its own*. Is this a problem or A Problem? * There's been some discussion of making EA.astype always return EA at some point, which I think would include this. 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. If you guys don't think so then no. I just wasn't aware of the historical context hence the ping - thanks for the insights. So @MarcoGorelli still should update the tests to use 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. Ok, thanks all for your feedback - I've updated the tests |
||
result = np.asarray(pd.Categorical(data).astype(dtype)) | ||
assert result == expected | ||
|
||
|
||
class TestArithmeticOps(base.BaseArithmeticOpsTests): | ||
def test_arith_series_with_scalar(self, data, all_arithmetic_operators): | ||
|
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.
Side note - since
data
is always the same no need to parametrize