-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: catch warnings from pandas in cbook._check_1d #16347
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
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 |
---|---|---|
|
@@ -1367,11 +1367,22 @@ def _check_1d(x): | |
return np.atleast_1d(x) | ||
else: | ||
try: | ||
ndim = x[:, None].ndim | ||
# work around https://github.com/pandas-dev/pandas/issues/27775 | ||
# which mean the shape is not as expected. That this ever worked | ||
# was an unintentional quirk of pandas the above line will raise | ||
# an exception in the future. | ||
# This warns in pandas >= 1.0 via | ||
# https://github.com/pandas-dev/pandas/pull/30588 | ||
with warnings.catch_warnings(record=True) as w: | ||
warnings.filterwarnings("always", | ||
category=DeprecationWarning, | ||
module='pandas[.*]') | ||
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. does this mean we're just kicking the can down the road and will need yet another fix when pandas actually change this behavior? 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 change will be to raise one of the Exceptions we already catch below so we will still be happy. 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. fair enough |
||
|
||
ndim = x[:, None].ndim | ||
# we have definitely hit a pandas index or series object | ||
# cast to a numpy array. | ||
if len(w) != 0: | ||
tacaswell marked this conversation as resolved.
Show resolved
Hide resolved
|
||
return np.asanyarray(x) | ||
if ndim < 2: | ||
return np.atleast_1d(x) | ||
return x | ||
|
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.
since the above line is getting deleted, this comment is no longer relevant.
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.
It is still relevant, the line above was moved down and put inside the context manager below.
Uh oh!
There was an error while loading. Please reload this page.
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, then it should be changed to "the line below" or moved to be next to the line it's referring to: