Skip to content
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

DOC: Suppress warnings in visualization.rst #8877

Merged
merged 1 commit into from
Feb 12, 2015

Conversation

sinhrks
Copy link
Member

@sinhrks sinhrks commented Nov 22, 2014

Closes #8234. Sorry to take a long.

I understand there are 2 warnings:

  1. Warning in /Users/sin/Documents/Git/pandas/doc/source/visualization.rst at block ending on line 1275
    This is raised from mpl as plotting empty axes for demonstration purpose. Thus simply suppressed.
  2. Warning in /Users/sin/Documents/Git/pandas/doc/source/visualization.rst at block ending on line 1312
    This is a warning displayed when passing multiple axes. Added explanations.

@jreback jreback added this to the 0.15.2 milestone Nov 22, 2014
@jreback
Copy link
Contributor

jreback commented Nov 22, 2014


@savefig frame_plot_subplots_layout.png
df.plot(subplots=True, layout=(3, 2), figsize=(6, 6), sharex=False);
df.plot(subplots=True, layout=(2, 3), figsize=(6, 6), sharex=False);
Copy link
Member

Choose a reason for hiding this comment

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

Is this change so you see better the empty axes?

Copy link
Member

Choose a reason for hiding this comment

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

The explanation on line 1293 is now no longer correct.

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes, fixed the text and example.

@jorisvandenbossche
Copy link
Member

@sinhrks these warnings also appear when running the tests, so probably there are also some of these calls that can be fixed (see https://travis-ci.org/pydata/pandas/jobs/42314766)

@jreback
Copy link
Contributor

jreback commented Dec 3, 2014

@sinhrks @jorisvandenbossche this ready to merge?

@jorisvandenbossche
Copy link
Member

just the tests, it would be good to take a look at that as well

@jreback
Copy link
Contributor

jreback commented Dec 6, 2014

@sinhrks can you see if you can fix the test warnings as well?

@jreback
Copy link
Contributor

jreback commented Dec 8, 2014

@jorisvandenbossche @sinhrks ?

@jreback
Copy link
Contributor

jreback commented Dec 11, 2014

@jorisvandenbossche ?

@jorisvandenbossche jorisvandenbossche modified the milestones: 0.16.0, 0.15.2 Dec 11, 2014
@jorisvandenbossche
Copy link
Member

bumbed to 0.16, as you don't visually see it in the docs (warning is not shown by sphinx), so no blocker

@sinhrks
Copy link
Member Author

sinhrks commented Dec 20, 2014

Sure, will fix tests also.

@sinhrks
Copy link
Member Author

sinhrks commented Jan 17, 2015

Updated, and prepared a separate fix #9278 for a program change.

@sinhrks sinhrks force-pushed the plot_doc branch 2 times, most recently from 36ee23b to 0b75ac9 Compare January 24, 2015 01:13
@sinhrks
Copy link
Member Author

sinhrks commented Jan 24, 2015

@jorisvandenbossche OK, now all the warnings should disapear. Pls check.

@jorisvandenbossche
Copy link
Member

Just looking at the travis log, I still see some warnings. Eg (in the log of the third job: https://travis-ci.org/pydata/pandas/jobs/48128130):

..................S.................................................../home/travis/build/pydata/pandas/pandas/tools/plotting.py:3225: UserWarning: To output multiple subplots, the figure containing the passed axes is being cleared

"is being cleared", UserWarning)

........../home/travis/build/pydata/pandas/pandas/tools/plotting.py:3208: UserWarning: When passing multiple axes, sharex and sharey are ignored.These settings must be specified when creating axes

"These settings must be specified when creating axes", UserWarning)

./home/travis/miniconda/envs/pandas/lib/python2.7/site-packages/matplotlib/axes.py:4747: UserWarning: No labeled objects found. Use label='...' kwarg on individual plots.

warnings.warn("No labeled objects found. "

It is not clear to me if you can see which test triggered the warnings.


returned = df.plot(subplots=True, ax=axes, layout=(-1, 2))
with warnings.catch_warnings():
warnings.simplefilter('ignore')
Copy link
Member

Choose a reason for hiding this comment

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

Why is the 'catch warnings' needed here? I thought that explicitly stating sharex=False, sharey=False (as you do in this test) is enough to suppress the warning? (that is what you added in the docs?)

Copy link
Member Author

Choose a reason for hiding this comment

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

Required, because the test specifies layout keyword which can't be effective when ax keyword is passed. I understand these tests was added in #8297, and intend to test layout is ignored properly.

@TomAugspurger ?

Copy link
Member

Choose a reason for hiding this comment

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

ah, that makes sense. Maybe explicitely test that the warning is triggered instead of ignoring it?

Copy link
Contributor

Choose a reason for hiding this comment

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

@sinhrks that sounds about right, but I could have added both the axes and layout kws without realizing that the layout would be ignored.

@jorisvandenbossche
Copy link
Member

@sinhrks add some questions

@TomAugspurger can you also give this a brief look?

@@ -4594,9 +4594,6 @@ def test_frame_groupby_plot_boxplot(self):
_skip_if_mpl_not_installed()

import matplotlib.pyplot as plt
import matplotlib as mpl
Copy link
Contributor

Choose a reason for hiding this comment

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

Was this causing warnings as well? I think I've seen warnings about trying to set the backend twice...

Copy link
Member Author

Choose a reason for hiding this comment

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

Yes it did, thus removed. Do you know the reason why these are added originally?

UserWarning: This call to matplotlib.use() has no effect because the the backend has already been chosen;
matplotlib.use() must be called *before* pylab, matplotlib.pyplot, or matplotlib.backends is 

Copy link
Member

Choose a reason for hiding this comment

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

The reason it causes a warning is because it is called after import matplotlib.pyplot as plt.
I was looking at the test_graphics, and there they also set the matplotlib backend, but in the test to skip it (https://github.com/sinhrks/pandas/blob/plot_doc/pandas/util/testing.py#L180). So you can also put it in the _skip_if_mpl_not_installed here. Only you have to import matplotlib in that test, and not matplotlib.pyplot

Copy link
Member Author

Choose a reason for hiding this comment

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

There is _skip_if_mpl_not_installed already. And I think matplotlib.pyplot must be installed here, because continuous test case accesses to pyplot.

So current fix (remove problematic part) looks OK if there is no specific reason to keep mpl.use.

Copy link
Member

Choose a reason for hiding this comment

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

I mean you can put the line in the existing _skip_if_mpl_not_installed. So adapt _skip_if_mpl_not_installed to import matplotlib and call mpl.use('Agg'), and then import pyplot here in the testµµ

I also don't exactly know why it is needed (maybe to run the tests where no graphical toolkit is avaliable?), but since all existing tests for plotting do this, I would keep it that way.

Copy link
Member Author

Choose a reason for hiding this comment

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

@jorisvandenbossche Understood what you mean. How about moving them to test_graphics.py to simplify.

Copy link
Member

Choose a reason for hiding this comment

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

Euhm, I would keep it here, as it really tests the plotting method of the GroupBy object. But maybe you could see if you can eg put the _skip_if_mpl_not_installed in util.testing for reuse.

Copy link
Member Author

Choose a reason for hiding this comment

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

Currently Groupby.plot is tested mostly under test_graphics.py, and plotting tests in test_groupby.py looks not maintained. Moving remaining to test_graphics is better for maintenance.
https://github.com/pydata/pandas/blob/master/pandas/tests/test_graphics.py#L2015

Separate issue is test_graphics gets larger though.

Copy link
Member

Choose a reason for hiding this comment

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

Ah I didn't know you had already a TestDataFrameGroupByPlots in test_graphics. Yep, certainly OK then to move the tests there.

But is seems a lot of the tests in TestDataFrameGroupByPlots don't really belong there (as it are just Series.plot tests)

Copy link
Member Author

Choose a reason for hiding this comment

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

Yeah, better to re-organize test_graphics. I'll issue separate one.

@sinhrks sinhrks force-pushed the plot_doc branch 2 times, most recently from a6dff05 to f99a8a7 Compare February 3, 2015 12:41
@sinhrks
Copy link
Member Author

sinhrks commented Feb 4, 2015

@TomAugspurger Thanks to confirm. I think everything done now.

@TomAugspurger
Copy link
Contributor

OK. I've only been able to give it a quick glance, but from that everything looks fine.

@jorisvandenbossche
Copy link
Member

Regarding my comment above (#8877 (comment)) the No labeled objects found. Use label='...' kwarg on individual plots. is still present in the tests, but this is more a leftover not addressed in #9278, so see if you can look at it

@sinhrks
Copy link
Member Author

sinhrks commented Feb 4, 2015

Yes, will do. I originally misunderstood you're referring to different line.

@jorisvandenbossche
Copy link
Member

@sinhrks This is ready to merge for you?

In any case, thanks for your endurance, this has been a long one ..

@sinhrks
Copy link
Member Author

sinhrks commented Feb 12, 2015

@jorisvandenbossche Yes. I expect all warnings should be disappears after this and #9464, otherwise will implement a fix in #9464.

jorisvandenbossche added a commit that referenced this pull request Feb 12, 2015
DOC: Suppress warnings in visualization.rst
@jorisvandenbossche jorisvandenbossche merged commit 2f41991 into pandas-dev:master Feb 12, 2015
@jorisvandenbossche
Copy link
Member

Thanks!
Maybe then rebase #9464 to be sure

@sinhrks sinhrks deleted the plot_doc branch February 15, 2015 01:33
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.

DOC: some errors in the vis docs regarding multiple axes
4 participants