Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

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 ourterms of service andprivacy statement. We’ll occasionally send you account related emails.

Already on GitHub?Sign in to your account

Merged

Conversation

tacaswell
Copy link
Member

@tacaswelltacaswell commentedJan 27, 2020
edited
Loading

If we catch the warning or the exception, we need to cast to numpy
because later on in_plot_args we again use multi-dimensional
indexing to up-cast to a 2D array.

closes#16295

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code isFlake 8 compliant

with warnings.catch_warnings() as w:
warnings.filterwarnings("ignore",
category=DeprecationWarning,
module='pandas[.*]')
Copy link
Contributor

Choose a reason for hiding this comment

The 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?

Copy link
MemberAuthor

Choose a reason for hiding this comment

The 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.

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others.Learn more.

fair enough

If we catch the warning or the exception, we need to cast to numpybecause later on in `_plot_args` we again use multi-dimensionalindexing to up-cast to a 2D array.closesmatplotlib#16295
@tacaswelltacaswellforce-pushed thefix_pandas_index_deprecation branch fromae4354c toc7eddd6CompareJanuary 27, 2020 23:33
@tacaswelltacaswell added this to thev2.2.5 milestoneJan 27, 2020
@tacaswelltacaswell added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelJan 28, 2020
@tacaswell
Copy link
MemberAuthor

@bashtage However on older versions we are not getting back a numpy array

In [1]:importpandasaspdIn [2]:d=pd.Series([])In [3]:d.index[:,None]Out[3]:Int64Index([],dtype='int64')In [4]:type(d.index[:,None])Out[4]:pandas.core.indexes.numeric.Int64IndexIn [5]:d.index[:,None].ndimOut[5]:1In [6]:pd.__version__Out[6]:'0.25.1'

Comment on lines 1372 to 1373
# was an unintentional quirk of pandas the above line will raise
# an exception in the future.
Copy link
Member

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.

Copy link
MemberAuthor

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.

Copy link
Member

@story645story645Jan 28, 2020
edited
Loading

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:

ndim=x[:,None].ndim#will raise exception in future

@jklymakjklymak merged commita7501f9 intomatplotlib:masterJan 28, 2020
@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v2.2.x$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 a7501f94988b952bd97a7b382b86c924cf464f62
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #16347: FIX: catch warnings from pandas in cbook._check_1d'
  1. Push to a named branch :
git push YOURFORK v2.2.x:auto-backport-of-pr-16347-on-v2.2.x
  1. Create a PR against branch v2.2.x, I would have named this PR:

"Backport PR#16347 on branch v2.2.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free tosuggest an improvement.

@lumberbot-app
Copy link

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
$ git checkout v3.1.x$ git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
$ git cherry-pick -m1 a7501f94988b952bd97a7b382b86c924cf464f62
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
$ git commit -am 'Backport PR #16347: FIX: catch warnings from pandas in cbook._check_1d'
  1. Push to a named branch :
git push YOURFORK v3.1.x:auto-backport-of-pr-16347-on-v3.1.x
  1. Create a PR against branch v3.1.x, I would have named this PR:

"Backport PR#16347 on branch v3.1.x"

And apply the correct labels and milestones.

Congratulation you did some good work ! Hopefully your backport PR will be tested by the continuous integration and merged soon!

If these instruction are inaccurate, feel free tosuggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull requestJan 28, 2020
@tacaswelltacaswell deleted the fix_pandas_index_deprecation branchJanuary 28, 2020 23:22
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull requestJan 28, 2020
…k._check_1dMerge pull requestmatplotlib#16347 from tacaswell/fix_pandas_index_deprecationFIX: catch warnings from pandas in cbook._check_1d Conflicts:lib/matplotlib/tests/test_axes.py         - new test in middle of section of tests not on v2.2.x yet, only kept           new test
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull requestJan 28, 2020
…k._check_1dMerge pull requestmatplotlib#16347 from tacaswell/fix_pandas_index_deprecationFIX: catch warnings from pandas in cbook._check_1d
tacaswell added a commit that referenced this pull requestJan 29, 2020
…347-on-v3.2.xBackport PR#16347 on branch v3.2.x (FIX: catch warnings from pandas in cbook._check_1d)
timhoffm added a commit that referenced this pull requestJan 29, 2020
…-v3.1.xBackport PR#16347: FIX: catch warnings from pandas in cbook._check_1d
timhoffm added a commit that referenced this pull requestJan 29, 2020
…-v2.2.xBackport PR#16347: FIX: catch warnings from pandas in cbook._check_1d
@jklymak
Copy link
Member

So,test_bar_pandas is still failing, at least w/#16286 which I rebased, so it should include this fix?

@jklymak
Copy link
Member

I guess because pandas 1.0 is out?

@jklymak
Copy link
Member

I actually don't understand. The warning is from pandas 1.0 (old pandas pass this test) and the result is:

E           DeprecationWarning: Support for multi-dimensional indexing (e.g. `index[:, None]`) on an Index is deprecated and will be removed in a future version.  Convert to a numpy array before indexing instead.

So somehow we are no longer capturing the warning.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@anntzeranntzeranntzer left review comments

@timhoffmtimhoffmtimhoffm left review comments

@story645story645story645 approved these changes

@jklymakjklymakjklymak approved these changes

Assignees
No one assigned
Labels
Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.
Projects
None yet
Milestone
v2.2.5
Development

Successfully merging this pull request may close these issues.

pyplot.plot using pandas series raises DeprecationWarning with pandas=1.0.0rc0
6 participants
@tacaswell@jklymak@story645@anntzer@timhoffm@bashtage

[8]ページ先頭

©2009-2025 Movatter.jp