-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN+TST: Catch specific exception in equals #28532
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
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.
lgtm. Do you know generally how many more except Exceptions
are left to tackle?
106 on master. A handful of those are correct as is, not sure how many (maybe we could alias Also a handful of |
Is this a case where we want to be broad in what we catch? Having equality checks never raise is convenient. |
That's not unreasonable. I lean towards being specific because it surfaces other bugs (like passing MultiIndex raising the wrong exception). |
I generally dislike |
@@ -1918,6 +1918,9 @@ def sequence_to_dt64ns( | |||
tz = validate_tz_from_dtype(dtype, tz) | |||
|
|||
if isinstance(data, ABCIndexClass): | |||
if data.nlevels > 1: | |||
# Without this check, data._data below is None | |||
raise TypeError("Cannot create a DatetimeArray from a MultiIndex.") |
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.
we should have an index method which does this no?
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.
For the check or the raising? The check could be isinstance(data, ABCMultiIndex)
. No strong preference.
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.
no, something that does the right thing on an Index/MultiIndex, e.g. that gets (data._data) on an index and just passes thru on a MI
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 think we want to move to use the extract_array
pattern here, but that currently raises ValueError on MultiIndex (where we want to raise TypeError 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.
ok the reason I am harping on this is its an inconsistency between Index and MultiIndex. ok on merging this and creating an issue / followup ?
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.
creating an issue / followup ?
yes
k cool |
No description provided.