Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Remove internal use of get/set dpi #23278

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 9 commits into from
Jun 17, 2022
Merged

Conversation

scottjones03
Copy link
Contributor

@scottjones03 scottjones03 commented Jun 15, 2022

PR Summary

There has been a mismatch between use dpi property and get/set methods internally. This has caused bugs for SubFigure objects. Please see my previous PR for more details on the issues.

PR Checklist

Tests and Styling

  • [ N/A] Has pytest style unit tests (and pytest passes).
  • Is Flake 8 compliant (install flake8-docstrings and run flake8 --docstring-convention=all).

Documentation

  • [ N/A] New features are documented, with examples if plot related.
  • [N/A] New features have an entry in doc/users/next_whats_new/ (follow instructions in README.rst there).
  • [N/A] API changes documented in doc/api/next_api_changes/ (follow instructions in README.rst there).
  • [N/A] Documentation is sphinx and numpydoc compliant (the docs should build without error).

@tacaswell tacaswell added this to the v3.5.3 milestone Jun 15, 2022
@tacaswell
Copy link
Member

@scottjones03 Would you be willing to add a that exercises the issue you found with saving pdfs? If I understood what you said in #23276 correctly, making a figure with a sub-figure and then saving as a pdf to a io.StringIO buffer would be enough?

@scottjones03
Copy link
Contributor Author

@scottjones03 Would you be willing to add a that exercises the issue you found with saving pdfs? If I understood what you said in #23276 correctly, making a figure with a sub-figure and then saving as a pdf to a io.StringIO buffer would be enough?

Sorry, slight confused, Do you want me to summarise reproducibility steps for the bug so it can be QAd?

@tacaswell
Copy link
Member

Sorry, slight confused, Do you want me to summarise reproducibility steps for the bug so it can be QAd?

Yes. I think this needs a test (probably in https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/tests/test_figure.py) that looks something like

from io import StringIO
def test_subfigure_pdf():
    fig = ...  # minimal code to make a broken figure
    buffer = StringIO()
    fig.savefig(buffer, format='pdf')

so that this bug can not come back.

@tacaswell tacaswell changed the title Deprecate internal use of get/set dpi remove internal use of get/set dpi Jun 15, 2022
@tacaswell
Copy link
Member

I also changed the title to something I think is a bit more accurate as to what is being done here. We (for better or worse) use "deprecate" as a term of art for the process by which we remove public API from the library, where as here we are "just" not using a part of the public API internally. A deprecation will get a lot more scrutiny than an internal refactor so the adjusted title will hopefully put reviewers in the right state of mind when they click on the PR.

@scottjones03
Copy link
Contributor Author

Sorry, slight confused, Do you want me to summarise reproducibility steps for the bug so it can be QAd?

Yes. I think this needs a test (probably in https://github.com/matplotlib/matplotlib/blob/main/lib/matplotlib/tests/test_figure.py) that looks something like

from io import StringIO
def test_subfigure_pdf():
    fig = ...  # minimal code to make a broken figure
    buffer = StringIO()
    fig.savefig(buffer, format='pdf')

so that this bug can not come back.

Done

Copy link
Member

@QuLogic QuLogic left a comment

Choose a reason for hiding this comment

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

Might was well fix a couple things if touching these lines.

scottjones03 and others added 4 commits June 15, 2022 21:31
Co-authored-by: Elliott Sales de Andrade <[email protected]>
Co-authored-by: Elliott Sales de Andrade <[email protected]>
Co-authored-by: Elliott Sales de Andrade <[email protected]>
Co-authored-by: Elliott Sales de Andrade <[email protected]>
@scottjones03 scottjones03 requested review from QuLogic and oscargus June 15, 2022 20:32
@oscargus
Copy link
Member

I'm not merging to give @QuLogic a chance to check (based on the review request, although I think it is OK).

@scottjones03 it is possible to do "Add suggestion to batch" and then do a single commit. Not a problem since we should squash the commits before merging, but often a bit easier.

@oscargus oscargus changed the title remove internal use of get/set dpi Remove internal use of get/set dpi Jun 16, 2022
@tacaswell tacaswell merged commit 047254d into matplotlib:main Jun 17, 2022
@lumberbot-app
Copy link

lumberbot-app bot commented Jun 17, 2022

Owee, I'm MrMeeseeks, Look at me.

There seem to be a conflict, please backport manually. Here are approximate instructions:

  1. Checkout backport branch and update it.
git checkout v3.5.x
git pull
  1. Cherry pick the first parent branch of the this PR on top of the older branch:
git cherry-pick -x -m1 047254dd0c5fcf602a19b245e3b14a38d1af1614
  1. You will likely have some merge/cherry-pick conflict here, fix them and commit:
git commit -am 'Backport PR #23278: Remove internal use of get/set dpi'
  1. Push to a named branch:
git push YOURFORK v3.5.x:auto-backport-of-pr-23278-on-v3.5.x
  1. Create a PR against branch v3.5.x, I would have named this PR:

"Backport PR #23278 on branch v3.5.x (Remove internal use of get/set dpi)"

And apply the correct labels and milestones.

Congratulations — you did some good work! Hopefully your backport PR will be tested by the continuous integration and merged soon!

Remember to remove the Still Needs Manual Backport label once the PR gets merged.

If these instructions are inaccurate, feel free to suggest an improvement.

@tacaswell
Copy link
Member

drat, I forgot to squash this (realized about a second after I clicked merge) 🤦🏻

@tacaswell
Copy link
Member

backport is a bit gnarly.

tacaswell added a commit to tacaswell/matplotlib that referenced this pull request Jun 24, 2022
Merge pull request matplotlib#23278 from scottjones03/main

FIX: Remove internal use of get_dpi/set_dpi
(cherry picked from commit 047254d)
timhoffm added a commit that referenced this pull request Jun 24, 2022
…-v3.5.x

Backport PR #23278: Remove internal use of get/set dpi
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.

5 participants