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

In imsave, let pnginfo have precedence over metadata.#15434

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 2 commits intomatplotlib:v3.2.xfromanntzer:imsave-priority
Oct 19, 2019

Conversation

anntzer
Copy link
Contributor

@anntzeranntzer commentedOct 17, 2019
edited
Loading

This is consistent with the documented behavior ("If the 'pnginfo' key
is present, it completely overridesmetadata, including the default
'Software' key.") and also with the behavior of
FigureCanvasAgg.print_png, cf

# Only use the metadata kwarg if pnginfo is not set, because the
# semantics of duplicate keys in pnginfo is unclear.
if"pnginfo"notinpil_kwargs:

The feature came in in#13902 which is not in any released version so far, so it would be nice if this was fixed before the final 3.2 release. I will prepare a separate PR for master.

PR Summary

PR Checklist

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

This is consistent with the documented behavior ("If the 'pnginfo' keyis present, it completely overrides *metadata*, including the default'Software' key.") and also with the behavior ofFigureCanvasAgg.print_png.
@anntzeranntzer added the Release criticalFor bugs that make the library unusable (segfaults, incorrect plots, etc) and major regressions. labelOct 17, 2019
@anntzeranntzer added this to thev3.2.0 milestoneOct 17, 2019
@timhoffm
Copy link
Member

Is#13092 really the relevant issue here?

@@ -1539,7 +1539,8 @@ def imsave(fname, arr, vmin=None, vmax=None, cmap=None, format=None,
pil_shape = (rgba.shape[1], rgba.shape[0])
image = Image.frombuffer(
"RGBA", pil_shape, rgba, "raw", "RGBA", 0, 1)
if format == "png" and metadata is not None:
if (format == "png"
and metadata is not None and "pnginfo" not in pil_kwargs):
Copy link
Member

@timhoffmtimhoffmOct 17, 2019
edited
Loading

Choose a reason for hiding this comment

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

Silently ignoringmetadata ifpnginfo is present does not feel right. Can we raise or warn in that case, or are there subsets of metadata that may still be needed?

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

print_png (used bysavefig("foo.png") has had this behavior ever since pil_kwargs is supported (which is 3.1), and no one has complained about it so far (it probably hasn't been too much used yet in the wild, though); I'd rather keep both places in sync.
Also a verb is missing in your sentence ("Can we ???").

Copy link
Member

Choose a reason for hiding this comment

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

Fixed the missing verb. I'd be happy to warn in both places. Raising would now be a breaking change.

I wouldn't expect too much complaint. It's not widely used, it will only happen if you provide both parameters. It might actually have affect users without them realizing it.

Copy link
ContributorAuthor

Choose a reason for hiding this comment

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

sure, added a warning in both places.

@anntzer
Copy link
ContributorAuthor

edited: the correct original PR was#13902.

@tacaswelltacaswell merged commitd687c21 intomatplotlib:v3.2.xOct 19, 2019
@tacaswell
Copy link
Member

The doc issue was fixed by#15449 .

@anntzeranntzer deleted the imsave-priority branchOctober 20, 2019 08:19
Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Reviewers

@timhoffmtimhoffmtimhoffm 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
v3.2.0
Development

Successfully merging this pull request may close these issues.

3 participants
@anntzer@timhoffm@tacaswell

[8]ページ先頭

©2009-2025 Movatter.jp