-
-
Notifications
You must be signed in to change notification settings - Fork 18.4k
CLN: remove bare excepts #14700
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 bare excepts #14700
Conversation
Current coverage is 84.55% (diff: 0.00%)@@ master #14700 diff @@
==========================================
Files 144 144
Lines 51043 51043
Methods 0 0
Messages 0 0
Branches 0 0
==========================================
Hits 43160 43160
Misses 7883 7883
Partials 0 0
|
@@ -1320,8 +1320,8 @@ def _getbool_axis(self, key, axis=0): | |||
inds, = key.nonzero() | |||
try: | |||
return self.obj.take(inds, axis=axis, convert=False) | |||
except Exception as detail: |
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.
instead of this, catch appropriate errors (and let others bubble up), and convert to the correct exception type. as written this is a big change in the API
@@ -1216,7 +1216,7 @@ def test_loc_getitem_bool(self): | |||
self.check_result('bool', 'loc', b, 'ix', b, | |||
typs=['ints', 'labels', 'mixed', 'ts', 'floats']) | |||
self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], | |||
fails=KeyError) |
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.
this is a major API change, pls revert
needs the test from the issue |
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.
please make the changes as indicated
I'm struggling with the intent of what's going on then. Indexing errors and key errors should be converted to key error, everything else (like the bug reports recursion error) shouldbubble up? Thanks for the understanding, This is one of my first non doc PRs. |
no they should be converted to the Its very important that the exceptions that are related to indexing are consistent (think from a user perspective). and so we don't/can't change them. However we may have an implementation that actually does positional type things (e.g. |
raise self._exception | ||
except: |
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.
you don't need an except here (it will default to raising).
you also don't need to catch self._exception
@@ -1218,6 +1222,18 @@ def test_loc_getitem_bool(self): | |||
self.check_result('bool', 'loc', b, 'ix', b, typs=['empty'], | |||
fails=KeyError) | |||
|
|||
def test_recursion_fails_loc(self): | |||
#GH14554 |
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.
you need a space after the comments
@@ -279,6 +278,11 @@ def _print(result, error=None): | |||
k2 = key2 | |||
_eq(t, o, a, obj, key1, k2) | |||
|
|||
#GH14554: used to make sure recursion errors bubble up as expected | |||
recursive_df = pd.DataFrame({'a':[1,]}, index=['a']) | |||
def recursive_indexing_function(self, a): |
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 we define this inside of the test function?
@jreback What's the best course of action here? Some of the builds are failing, but for conflicting reasons. 3.4 is blowing the stack, 3.5 is failing because it because the recursion limit is being set to low. I've reached an impasse in googling. Something doesn't smell right in artificially setting the |
return recursive_indexing_function( | ||
recursive_df[['a'], ['a']]) | ||
|
||
oldVal=sys.getrecursionlimit() |
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.
why are you changing the recursion limit at all?
just let the assert happen naturally.
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.
If I exclude it, when I run the tests, my stack just blows up, and the exception doesn't bubble up.
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.
yeah this seems kind of extreme. why don't you just remove this test and leave your change. pls add a whatsnew note (for 0.20.0), and we'll call it a day :>
of course give it a manual test that things work
@jreback Updated and squashed. |
can you rebase and push again. like to see this all green. |
My git-foo was all jacked up. I have no idea what happened. Please let me know if current push works. |
@clham Can you push again? For some reason, the tests didn't run |
Done. Still seems not to be triggering. Should I try adding a commit? |
Can you fix the merge conflict and in the whatsnew file, and push that? |
made a change and repushed: still doesn't appear to be getting pulled into Travis or AppVeyor. Conflict was also resolved. it is only a few small changes. does it make sens to nuke the branch and submit a fresh PR? |
resubmitted as #14912 . Just starting over to make the pain stop. |
git diff upstream/master | flake8 --diff
Errors in indexing no longer forced into KeyError