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

Appearance settings

Simplify implementation of svg.image_inline. #14454

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

Merged
merged 1 commit into from
Jun 8, 2019

Conversation

anntzer
Copy link
Contributor

@anntzer anntzer commented Jun 5, 2019

RendererSVG._imaged is basically a single-entry dict (because
Renderer.basename never changes), so just replace it by a counter.

Also replace the assert by a proper exception, and only trigger it if
the user actually tries to save an image while the filesystem path is
unknown (otherwise, there's no problem).

The whole svg.image_inline system could probably use a test...

PR Summary

PR Checklist

  • Has Pytest style unit tests
  • Code is Flake 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

Copy link
Member

@timhoffm timhoffm left a comment

Choose a reason for hiding this comment

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

Not tested, but could a user change basename? E.g.

renderer.basename = 'file_a'
renderer.draw_image()
renderer.basename = 'file_b'
renderer.draw_image()

Until now he would have gotten file_a0, file_b0.
Now it will be file_a0, file_b1.

We could still have a dict of counters per basename if we want to keep that compatibility exactly.

@anntzer anntzer force-pushed the svg.image_inline branch 2 times, most recently from 8737b3e to 19f00e5 Compare June 8, 2019 12:50
@anntzer
Copy link
Contributor Author

anntzer commented Jun 8, 2019

  • I don't think it's a realistic use case (if someone really wants to fully control the external image paths, overwriting basename only gives them very limited control over that anyways), but added an API note just in case...
  • In any case, the SVG would be remain valid because the hrefs still point to the correct paths.

doc/api/next_api_changes/2019-06-10-AL.rst Show resolved Hide resolved
RendererSVG._imaged is basically a single-entry dict (because
Renderer.basename never changes), so just replace it by a counter.

Also replace the assert by a proper exception, and only trigger it if
the user actually tries to save an image while the filesystem path is
unknown (otherwise, there's no problem).
@anntzer anntzer force-pushed the svg.image_inline branch from 19f00e5 to 3c9e398 Compare June 8, 2019 13:11
@tacaswell tacaswell added this to the v3.2.0 milestone Jun 8, 2019
@tacaswell tacaswell merged commit 7c224b5 into matplotlib:master Jun 8, 2019
@anntzer anntzer deleted the svg.image_inline branch June 8, 2019 20:52
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants
Morty Proxy This is a proxified and sanitized view of the page, visit original site.