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 deprecations in examples#10385

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
tacaswell merged 3 commits intomatplotlib:masterfromQuLogic:example-deprecations
Feb 9, 2018

Conversation

QuLogic
Copy link
Member

PR Summary

This fixes several deprecation warnings that are triggered by the examples.

Currently,plt.plotfile callsmlab.csv2rev, which is deprecated. Because that function provides some automatic converters, I could not replace it withnp.genfromtxt ornp.loadtxt right away, as that would be a behaviour change. Even the examples take advantage of this behaviour.

plt.plotfile also triggers a warning about re-using anAxes spec. I have not looked too deeply into fixing that one.

PR Checklist

  • Has Pytest style unit tests
  • Code is PEP 8 compliant
  • [N/A] New features are documented, with examples if plot related
  • [N/A] Documentation is sphinx and numpydoc compliant
  • [N/A] Added an entry to doc/users/next_whats_new/ if major new feature (follow instructions in README.rst there)
  • [N/A] Documented in doc/api/api_changes.rst if API changed in a backward-incompatible way

The normal colorbar works fine if calling colorbar.set_ticks instead ofcolobar.ax.set_ticks, which is noted in the deprecation warning. Thereis no real benefit of showing the axes_grid1 version now.
Unfortunately, csv2rec provides some automatic converters, so it can'tbe replaced entirely with np.genfromtxt or np.loadtxt.
@QuLogicQuLogic added this to thev2.2 milestoneFeb 6, 2018
@QuLogic
Copy link
MemberAuthor

There are also a few warnings abouttight_layout which I don't know how to fix; maybe@jklymak has an idea.

datafile = cbook.get_sample_data('msft.csv', asfileobj=False)
print('loading %s' % datafile)
r = csv2rec(datafile)[-40:]
r = np.genfromtxt(datafile, delimiter=',', names=True,
Copy link
Member

Choose a reason for hiding this comment

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

Maybe use a more telling name likemsft_data instead ofr?

@jklymak
Copy link
Member

Oh, hmmm, that should give a warning, but for constrained layout, not tight layout! Ooops..

lib/matplotlib/tests/test_constrainedlayout.py::test_constrained_layout7[png]  /home/travis/build/matplotlib/matplotlib/lib/matplotlib/figure.py:2269: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.    warnings.warn("This figure includes Axes that are not compatible "

@QuLogic
Copy link
MemberAuthor

@jklymak Actually, I was referring to the examples, not the tests. For example,

generating gallery for gallery/lines_bars_and_markers... [ 97%] markevery_demo.py/home/circleci/project/lib/matplotlib/figure.py:2269: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.  warnings.warn("This figure includes Axes that are not compatible "generating gallery for tutorials/intermediate... [ 83%] tight_layout_guide.py/home/circleci/project/lib/matplotlib/gridspec.py:316: UserWarning: This figure includes Axes that are not compatible with tight_layout, so results might be incorrect.  warnings.warn("This figure includes Axes that are not compatible "generating gallery for tutorials/intermediate... [100%] constrainedlayout_guide.py/home/circleci/project/lib/matplotlib/figure.py:2224: UserWarning: Calling figure.constrained_layout, but figure not setup to do constrained layout.     You either called GridSpec without the fig keyword, you are using plt.subplot, or you need to call figure or subplotswith the constrained_layout=True kwarg.  warnings.warn("Calling figure.constrained_layout, but figure "

@jklymak
Copy link
Member

The last one is mine, and on purpose to show the failure in the tutorial.

Thetight_layout example is similar, showing that tight_layout doesn't work and emits a warning for colorbars created outside of gridspec. Not sure about the first one.

@QuLogicQuLogic added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelFeb 8, 2018
@@ -2411,8 +2411,11 @@ def plotfile(fname, cols=(0,), plotfuncs=None,

if plotfuncs is None:
plotfuncs = dict()
r = mlab.csv2rec(fname, comments=comments, skiprows=skiprows,
checkrows=checkrows, delimiter=delimiter, names=names)
from matplotlib.cbook import mplDeprecation
Copy link
Member

Choose a reason for hiding this comment

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

Should this whole method be deprecated since it depends oncsv2rec?

Copy link
Member

Choose a reason for hiding this comment

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

Yes, and point people at pandas.

Copy link
MemberAuthor

Choose a reason for hiding this comment

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

You want to deprecateplt.plotfile for Pandas? Probably should be an independent PR.

dstansby and tacaswell reacted with thumbs up emoji
@tacaswelltacaswell merged commit83d614b intomatplotlib:masterFeb 9, 2018
@QuLogicQuLogic deleted the example-deprecations branchFebruary 9, 2018 22:26
@QuLogicQuLogic modified the milestones:needs sorting,v2.2.0Feb 12, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@tacaswelltacaswelltacaswell left review comments

@timhoffmtimhoffmtimhoffm left review comments

@dstansbydstansbydstansby 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.0
Development

Successfully merging this pull request may close these issues.

5 participants
@QuLogic@jklymak@tacaswell@timhoffm@dstansby

[8]ページ先頭

©2009-2025 Movatter.jp