Skip to content

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

Merged
merged 3 commits into from
Sep 26, 2019

Conversation

jbrockmendel
Copy link
Member

No description provided.

@WillAyd WillAyd added the Clean label Sep 19, 2019
Copy link
Member

@WillAyd WillAyd left a 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?

@jbrockmendel
Copy link
Member Author

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 AnyException = Exception and so that grepping for "except Exception" doesn't turn those up? just brainstorming)

Also a handful of BaseException in test_nanops that we really shouldn't be catching. Looks like we got rid of all the except:.

@TomAugspurger
Copy link
Contributor

Is this a case where we want to be broad in what we catch? Having equality checks never raise is convenient.

@jbrockmendel
Copy link
Member Author

Is this a case where we want to be broad in what we catch?

That's not unreasonable. I lean towards being specific because it surfaces other bugs (like passing MultiIndex raising the wrong exception).

@WillAyd
Copy link
Member

WillAyd commented Sep 20, 2019

I generally dislike except Exception - maybe we find some other case we haven't discovered but would also prefer to be explicit with that when it surfaces

@jreback jreback added this to the 1.0 milestone Sep 20, 2019
@@ -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.")
Copy link
Contributor

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?

Copy link
Member Author

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.

Copy link
Contributor

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

Copy link
Member Author

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)

Copy link
Contributor

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 ?

Copy link
Member Author

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

@jreback jreback merged commit 31ae3f0 into pandas-dev:master Sep 26, 2019
@jreback
Copy link
Contributor

jreback commented Sep 26, 2019

k cool

@jbrockmendel jbrockmendel deleted the faster19 branch September 26, 2019 15:13
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
proost pushed a commit to proost/pandas that referenced this pull request Dec 19, 2019
bongolegend pushed a commit to bongolegend/pandas that referenced this pull request Jan 1, 2020
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants