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

Consolidate agg-buffer examples.#11726

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
jklymak merged 1 commit intomatplotlib:masterfromanntzer:canvasagg-examples
Jul 26, 2018

Conversation

@anntzer
Copy link
Contributor

@anntzeranntzer commentedJul 21, 2018
edited
Loading

agg_oo_sgskip, webapp_demo_sgskip, and histogram_demo_canvasagg_sgskip
were all demonstrating the same thing (how to create a Figure outside of
pyplot, attach a canvas, and get the data out either saved to a file or
as a string. Consolidate them into a single example, with the minimal
amount of plotting. (PIL.Image.frombytes exists since Pillow 2.0 which
is the first version to support Py3.)

agg_buffer is very similar but uses another (worse?) technique to attach
an agg buffer; make data extraction simpler but otherwise keep it
separate for now.

Other related examples include:

  • agg_buffer_to_array which directly does
    np.asarray(canvas.renderer._renderer), which is on the one side bad
    as it uses a private API, but on the other hand the only way (AFAIK)
    to access the underlying buffer without copy[*];
  • print_stdout_sgskip, which does use pyplot to set up the agg buffer.

Let's defer the discussion for these two examples to later.

[*] The poorly named buffer_rgba method actually does a copy (in PyBytes_FromStringAndSize). Note that the Py2 version used to return a Py2 buffer object, with no copy (https://github.com/matplotlib/matplotlib/blob/v2.2.2/src/_backend_agg_wrapper.cpp#L589). This (the buffer protocol) is also already implemented by the renderer object itself; it's just a matter of publically exposing it.

PR Summary

PR Checklist

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

agg_oo_sgskip, webapp_demo_sgskip, and histogram_demo_canvasagg_sgskipwere all demonstrating the same thing (how to create a Figure outside ofpyplot, attach a canvas, and get the data out either saved to a file oras a string.  Consolidate them into a single example, with the minimalamount of plotting.  (PIL.Image.frombytes exists since Pillow 2.0 whichis the first version to support Py3.)agg_buffer is very similar but uses another (worse?) technique to attachan agg buffer; make data extraction simpler but otherwise keep itseparate for now.Other related examples include:- agg_buffer_to_array which directly does  `np.asarray(canvas.renderer._renderer)`, which is on the one side bad  as it uses a private API, but on the other hand the only way (AFAIK)  to access the underlying buffer without copy;- print_stdout_sgskip, which does use pyplot to set up the agg buffer.Let's defer the discussion for these two examples to later.
@ImportanceOfBeingErnest
Copy link
Member

At leastagg_oo_sgskip is always been a standard example for people to link to from outside. Now the link adress has changed as it moved to/misc/, but at least the title did stay the same, so it's possible to find. If that example now vanishes, those links get completely broken. Is it necessary to completely remove it? I guess there is no way to do a http redirection for examples, right?


I know thatcanvas.renderer._renderer fails for some backends, at least for PyCharm's InterAgg. A bulletproof alternative would sure be desireable.

@anntzer
Copy link
ContributorAuthor

I don't mind moving everything to agg_oo_buffer instead if that makes you more comfortable.

@ImportanceOfBeingErnest
Copy link
Member

Ok, thinking about it, those links are broken anyways, so one needs to locate the examples through search anyways. The new name and title are much better now, so this is probably the more sustainable solution.
So what about mentioning the old names of the examples in the text, such that search finds them, something like

Note that this examples contains the content of the former agg_oo_sgskip, webapp_demo_sgskip, and histogram_demo_canvasagg_sgskip examples.

possibly in smaller font (if there exists a spinx rule for that).

@anntzer
Copy link
ContributorAuthor

The link to agg_oo_sgkip won't be broken if I move everything to it...

@ImportanceOfBeingErnest
Copy link
Member

Itis already broken. Versions of that example:

meaning that if it's moved again now, the link will be as broken as if you didn't do anything to it, because I strongly doubt that new links to the devdocs (devdocs/gallery/misc/agg_oo_sgskip.html) are already beeing created somewhere.

@anntzer
Copy link
ContributorAuthor

Let's just leave this as it is then? I know that@tacaswell has thought about examples redirection but I'd rather have a general solution before starting to pepper docs with refs to no-longer-existing docs.

@ImportanceOfBeingErnest
Copy link
Member

Ok, someone decided to break that link prior to this. So assuming there was a reason for this and since it got approved, this PR just builds on top and is fine by itself.

@jklymakjklymak merged commit0887e2a intomatplotlib:masterJul 26, 2018
@anntzeranntzer deleted the canvasagg-examples branchJuly 26, 2018 22:01
@QuLogicQuLogic modified the milestones:v3.1,v3.0Jul 26, 2018
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment

Reviewers

@jklymakjklymakjklymak approved these changes

Assignees

No one assigned

Projects

None yet

Milestone

v3.0.0

Development

Successfully merging this pull request may close these issues.

5 participants

@anntzer@ImportanceOfBeingErnest@jklymak@tacaswell@QuLogic

[8]ページ先頭

©2009-2025 Movatter.jp