-
-
Notifications
You must be signed in to change notification settings - Fork 199
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
utilities.py: metadata bug in make_figs() #1375
Comments
The reason for suppressing the CreationDate was that when the code gets run, even if the image part of a regenerated figure is bit-by-bit identical to the corresponding part of the former figure, if each of them is stamped with a different CreationDate git will declare that the files have changed.
Omitting the CreationDate from the metadata therefore enormously reduced the number of files that git identified as different.
If matplotlib has been modified to exclude the creation date and other metadata by default, this workaround to prevent it from including CreationDate should be no longer needed.
From: kennetheva ***@***.***>
Date: Monday, January 29, 2024 at 15:50
To: econ-ark/HARK ***@***.***>
Cc: Subscribed ***@***.***>
Subject: [econ-ark/HARK] utilities.py: metadata bug in make_figs() (Issue #1375)
When calling make_figs(), an unrecognized argument error occurs at:
plt.savefig(
os.path.join(target_dir, f"{figure_name}.jpg"),
metadata={"CreationDate": None},
)
The matplotlib.pyplot.savefig documentation<https://matplotlib.org/stable/api/_as_gen/matplotlib.pyplot.savefig.html> says metadata is currently not supported for .jpeg files. Commenting out the metadata argument stops the error and the figure is produced as expected.
Should metadata={"CreationDate": None} be removed from the JPEG savefig call until support is added in a later version of the package?
—
Reply to this email directly, view it on GitHub<#1375>, or unsubscribe<https://github.com/notifications/unsubscribe-auth/AAKCK74X7ZEOV766IUAMVHLYRADQ3AVCNFSM6AAAAABCQDEK5GVHI2DSMVQWIX3LMV43ASLTON2WKOZSGEYDMMZZGY3DQNA>.
You are receiving this because you are subscribed to this thread.Message ID: ***@***.***>
|
It might be better to use |
Matt, As the original author of savefig, can you look into this? I'm puzzled that a lot more examples have not cropped up. Also, my preference would be that whenever a figure is saved, it gets saved in jpg, pdf, svg, and png forms. |
Sure, but I don't actually remember writing it. Maybe it was just a very,
very long time ago?
…On Fri, Feb 2, 2024 at 10:12 AM Christopher Llorracc Carroll < ***@***.***> wrote:
Matt,
As the original author of savefig, can you look into this? I'm puzzled
that a lot more examples have not cropped up.
Also, my preference would be that whenever a figure is saved, it gets
saved in jpg, pdf, svg, and png forms.
—
Reply to this email directly, view it on GitHub
<#1375 (comment)>,
or unsubscribe
<https://github.com/notifications/unsubscribe-auth/ADKRAFNZGSCFSYCES7L6MGDYRT65TAVCNFSM6AAAAABCQDEK5GVHI2DSMVQWIX3LMV43OSLTON2WKQ3PNVWWK3TUHMYTSMRUGA3TKMBXGQ>
.
You are receiving this because you are subscribed to this thread.Message
ID: ***@***.***>
|
Well, I don't remember writing it either but as you say it was in a galaxy far far away so maybe I did. I do remember adding some code to suppress metadata, but I think that that was in a version that saved all four kinds of figures automatically (jpg, svg, pdf, png) and I worked out how to suppress the metadata for all of them (because there would be no point in suppressing it for just one). In any case, I'm puzzled that the problem has not cropped up for any of our REMARKs or other tests, so maybe none of them uses savefig. Actually, @edmundcrawley, can you point Matt to the place in the HAFiscal-Latest code where the savefig command is invoked, so he can see the content (I've just invited him as a collaborator on HAFiscal-Latest; please let Matt know the name of the branch you've been testing against HARK 0.13 on.) |
@mnwhite here is a minimal working example that shows the problem - that is probably easier than pointing you to the code in HAFiscal-Latest. Let me know if this doesn't work for you. from HARK.utilities import make_figs plt.figure() I get the error: TypeError: print_jpg() got an unexpected keyword argument 'metadata' |
Thanks @edmundcrawley , that was a perfect example. I've made a PR that fixes this in #1386 and will merge ASAP, then try to do a minor release. |
When calling make_figs(), an unrecognized argument error occurs at:
The matplotlib.pyplot.savefig documentation says metadata is currently not supported for .jpeg files. Commenting out the metadata argument stops the error and the figure is produced as expected.
Should
metadata={"CreationDate": None}
be removed from the JPEG savefig call until support is added in a later version of the package?The text was updated successfully, but these errors were encountered: