Skip to content

Simplify SubplotParams.update(). - #15200

Merged
jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:subplotpars
Oct 1, 2019
Merged

jklymak merged 1 commit into
matplotlib:masterfrom
anntzer:subplotpars

Conversation

@anntzer

@anntzer anntzer commented Sep 6, 2019

Copy link
Copy Markdown
Contributor

by moving initialization, well, to __init__.

Also improve the class docstring.

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

@tacaswell tacaswell added this to the v3.3.0 milestone Sep 6, 2019
Comment thread lib/matplotlib/figure.py Resolved
Comment thread lib/matplotlib/figure.py Resolved
by moving initialization, well, to `__init__`.

Also improve the class docstring.
@ImportanceOfBeingErnest

Copy link
Copy Markdown
Member

There was an attempt to make subplots_adjust more user friendly in #11086, based on issue #11059.

@anntzer

anntzer commented Sep 8, 2019 •

Copy link
Copy Markdown
Contributor Author

I wrote this as a consequence of reviewing #11086, indeed. This PR doesn't change any of the current behavior, though.

Comment thread lib/matplotlib/figure.py
val = rcParams[key]

setattr(self, s, val)
if left is not None:

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

why don't you just move the assignment above the check so the check doesn't have to be so complicated? You will error out anyway is the check says to

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

Because the subplotparams instance would have been modified at that point, and would be left in an inconsistent state (e.g. if someone catches the exception -- they'll still be left with an unusable subplotparams).

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

... but they passed in unusable subplotparams. Are you saying they should have the defaults even if they passed in incorrect ones?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

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

No, if someone passes unusable subplotparams we should immediately error out without modifying the subplotparams instance, so it'll stay in a usable state.

@jklymak
jklymak merged commit e3e864c into matplotlib:master Oct 1, 2019
@anntzer
anntzer deleted the subplotpars branch October 1, 2019 17:45
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

6 participants