-
-
Notifications
You must be signed in to change notification settings - Fork 18.5k
CLN: remove unnecessary check needs_i8_conversion
if Index subclass does not support any
or all
#58006
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
CLN: remove unnecessary check needs_i8_conversion
if Index subclass does not support any
or all
#58006
Changes from 2 commits
c3cf9a1
54983c5
3b2242f
c253533
923aa2f
0b71ac1
01ce724
add58c0
be3ab97
18fab28
c887a85
bac52c5
6efebb8
4ff9cea
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 |
---|---|---|
|
@@ -212,22 +212,24 @@ def test_numeric_compat(self, simple_index): | |
with pytest.raises(TypeError, match=floordiv_err): | ||
1 // idx | ||
|
||
def test_logical_compat(self, simple_index): | ||
def test_logical_compat(self, simple_index, request): | ||
if simple_index.dtype in (object, "string"): | ||
pytest.skip("Tested elsewhere.") | ||
idx = simple_index | ||
|
||
if idx.dtype.kind in "iufcbm": | ||
assert idx.all() == idx._values.all() | ||
assert idx.all() == idx.to_series().all() | ||
assert idx.any() == idx._values.any() | ||
assert idx.any() == idx.to_series().any() | ||
msg = "cannot perform (any|all) with this index type: Index" | ||
|
||
if request.node.callspec.id in [ | ||
"".join(["simple_index", t]) for t in ["1", "2", "3", "5", "6", "7"] | ||
]: | ||
with pytest.raises(TypeError, match=msg): | ||
assert idx.all() == idx._values.all() | ||
assert idx.all() == idx.to_series().all() | ||
assert idx.any() == idx._values.any() | ||
assert idx.any() == idx.to_series().any() | ||
else: | ||
msg = "cannot perform (any|all)" | ||
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 think you can delete L225-L228? i.e. the only thing needed here to pass tests is 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. thanks, I deleted the branch with 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. Oh OK I see the issue now. So you are branching because DatetimeIndex says I don't want to go down a rabbit hole but having a message that differs between operation: and reduction doesn't seem that important. How hard is it to align them so you can just assign 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. L225 looks like it can be safely deleted |
||
if isinstance(idx, IntervalIndex): | ||
msg = ( | ||
r"'IntervalArray' with dtype interval\[.*\] does " | ||
"not support reduction '(any|all)'" | ||
) | ||
with pytest.raises(TypeError, match=msg): | ||
idx.all() | ||
with pytest.raises(TypeError, match=msg): | ||
|
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.
is the != "m" bit still needed?
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.
Thanks for the comment. I think we don't need
!= "m"
here. This check worked only together with the checkneeds_i8_conversion(self.dtype)
.I removed
!= "m"
and corrected tests.I have a question: shouldn't we raise for
DatetimeIndex
? So far we showFutureWarning
:"'any' with datetime64 dtypes is deprecated and will raise in a future version. Use (obj != pd.Timestamp(0)).any() instead."
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.
there is a deprecation in nanany and nanall that i think is intended to be enforced before this needs_i8_conversion check is removed
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.
thanks, it was my thought too.
Should I open new PR to enforce the deprecation in
nanany
andnanall
, or can I do it in this PR?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 enforced deprecation
any/all
withdatetime64
in #58029