-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Normalize gridspec ratios to lists in the setter. #17291
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
.. though I guess the test failure is real? |
at some point I figured out how to look at the failing images on CI, but I cannot figure it out again :-( |
Artifacts are here |
lib/matplotlib/gridspec.py
Outdated
@@ -49,9 +49,9 @@ def __init__(self, nrows, ncols, height_ratios=None, width_ratios=None): | |||
|
|||
def __repr__(self): | |||
height_arg = (', height_ratios=%r' % (self._row_height_ratios,) | |||
if self._row_height_ratios is not None else '') | |||
if len({*self._row_height_ratios}) != 1 else '') |
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.
Slightly prefer
if len({*self._row_height_ratios}) != 1 else '') | |
if len(set(self._row_height_ratios)) != 1 else '') |
for better readability (also below).
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.
I think I already won this battle: there's multiple occurrences of {*foo}
in the codebase already and none of set(*foo)
:-)
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.
Um, set(*foo)
is not valid. It's set(foo)
because set()
takes a single iterable as argument.
That's part of why I prefer it here: "make as set from this list" is just a single concept, whereas "unpack this iterable and create a set from its elements" is two concepts. (I don't have that much brain capacity https://youtu.be/UANN2Eu6ZnM 😄).
Yes, you've already sneaked 5 times {*foo}
into the code base. - I hope I didn't approve these 😝.
But for real, {*a, *b}
makes sense for multiple iterables, but for a single iterable set(a)
is more readable than {*a}
.
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.
sure, changed to set().
Actually that looks like a real failure, see #17304. |
Currently blocked by #17304. |
fb8ddd1
to
583340e
Compare
hopefully working now |
Looks like another failure in test_pickle, but that one already has a nonzero tolerance for certain architectures which suggests fp issues so I don't feel bad putting in the same tolerance for x86_64. |
This avoids having to check for `ratios == None` every time someone actually accesses the ratios. I just deleted the never used and private `vstackeq` and `hstackeq` instead of changing their signatures to make height_ratios/width_ratios non-optional, given that they should be simple enough to bring back if needed.
This avoids having to check for
ratios == None
every time someoneactually accesses the ratios.
I just deleted the never used and private
vstackeq
andhstackeq
instead of changing their signatures to make height_ratios/width_ratios
non-optional, given that they should be simple enough to bring back if
needed.
PR Summary
PR Checklist