-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Simplify SubplotParams.update(). #15200
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
Conversation
by moving initialization, well, to `__init__`. Also improve the class docstring.
I wrote this as a consequence of reviewing #11086, indeed. This PR doesn't change any of the current behavior, though. |
val = rcParams[key] | ||
|
||
setattr(self, s, val) | ||
if left is not None: |
There was a problem hiding this comment.
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
There was a problem hiding this comment.
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).
There was a problem hiding this comment.
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?
There was a problem hiding this comment.
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.
by moving initialization, well, to
__init__
.Also improve the class docstring.
PR Summary
PR Checklist