FazBrowse GitHub Viewer | Trending |
URL:
| Home
Tools: [Download Repo ZIP]   [Original HTTPS Page]

FIX: catch warnings from pandas in cbook._check_1d by tacaswell · Pull Request #16347 · matplotlib/matplotlib · GitHub

Repository navigation

FIX: catch warnings from pandas in cbook._check_1d - #16347

Merged
jklymak merged 3 commits into
matplotlib:masterfrom
tacaswell:fix_pandas_index_deprecation
Jan 28, 2020
Merged

jklymak merged 3 commits into
matplotlib:masterfrom
tacaswell:fix_pandas_index_deprecation

Conversation

tacaswell commented Jan 27, 2020 •
edited
Loading

Copy link
Copy Markdown
Member

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 is Flake 8 compliant

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

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

The change will be to raise one of the Exceptions we already catch below so we will still be happy.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

fair enough

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 matplotlib#16295
tacaswell force-pushed the fix_pandas_index_deprecation branch from ae4354c to c7eddd6 Compare January 27, 2020 23:33
tacaswell added this to the v2.2.5 milestone Jan 27, 2020
tacaswell added the Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. label Jan 28, 2020

Copy link
Copy Markdown
Member Author

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

In [1]: import pandas as pd                                                                                                                                                                                                                                   

In [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.Int64Index

In [5]: d.index[:, None].ndim                                                                                                                                                                                                                                 
Out[5]: 1

In [6]: pd.__version__                                                                                                                                                                                                                                        
Out[6]: '0.25.1'

Comment thread lib/matplotlib/cbook/__init__.py Outdated
Comment on lines 1372 to 1373
# was an unintentional quirk of pandas the above line will raise
# an exception in the future.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

since the above line is getting deleted, this comment is no longer relevant.

Copy link
Copy Markdown
Member Author

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

It is still relevant, the line above was moved down and put inside the context manager below.

story645 Jan 28, 2020 •
edited
Loading

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

Choose a reason Spam Abuse Off Topic Outdated Duplicate Resolved Low Quality

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

Comment thread lib/matplotlib/cbook/__init__.py Outdated
Comment thread lib/matplotlib/tests/test_axes.py Outdated
tacaswell requested a review from story645 January 28, 2020 21:07
jklymak merged commit a7501f9 into matplotlib:master Jan 28, 2020

lumberbot-app Bot commented Jan 28, 2020

Copy link
Copy Markdown

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 to suggest an improvement.

lumberbot-app Bot commented Jan 28, 2020

Copy link
Copy Markdown

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 to suggest an improvement.

meeseeksmachine pushed a commit to meeseeksmachine/matplotlib that referenced this pull request Jan 28, 2020
tacaswell deleted the fix_pandas_index_deprecation branch January 28, 2020 23:22
tacaswell pushed a commit to tacaswell/matplotlib that referenced this pull request Jan 28, 2020
…k._check_1d

Merge pull request matplotlib#16347 from tacaswell/fix_pandas_index_deprecation

FIX: 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 request Jan 28, 2020
…k._check_1d

Merge pull request matplotlib#16347 from tacaswell/fix_pandas_index_deprecation

FIX: catch warnings from pandas in cbook._check_1d
tacaswell added a commit that referenced this pull request Jan 29, 2020
…347-on-v3.2.x

Backport PR #16347 on branch v3.2.x (FIX: catch warnings from pandas in cbook._check_1d)
timhoffm added a commit that referenced this pull request Jan 29, 2020
…-v3.1.x

Backport PR #16347: FIX: catch warnings from pandas in cbook._check_1d
timhoffm added a commit that referenced this pull request Jan 29, 2020
…-v2.2.x

Backport PR #16347: FIX: catch warnings from pandas in cbook._check_1d

jklymak commented Jan 30, 2020

Copy link
Copy Markdown
Member

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

jklymak commented Jan 30, 2020

Copy link
Copy Markdown
Member

I guess because pandas 1.0 is out?

jklymak commented Jan 30, 2020

Copy link
Copy Markdown
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.

This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode characters
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

Release critical For bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

pyplot.plot using pandas series raises DeprecationWarning with pandas=1.0.0rc0

6 participants


Back | FazBrowse Home | New Git URL