-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
FIX: Handle no-offsets in collection datalim (alternative) #22946
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
This adds a check for whether the collection has offsets passed in initially. This is necessary to handle the (0, 0) offset case that is desired and distinguishing that from the initial empty offset of (0, 0). In particular, this is necessary for the non-transData IdentityTransform passed in during tight_layout calculations.
lib/matplotlib/collections.py
Outdated
# default to zeros | ||
self._offsets = np.zeros((1, 2)) | ||
|
||
self._offsets = offsets |
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.
Could one move this to after the if-clause? (And more the identical line out of it.)
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.
Yep, good call, updated.
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.
Didn't know there was a get_offset
method already. Then I think this is probably a slightly better approach.
This avoids carrying around an extra offsetsNone/has_offsets variable to keep track of the default case. Instead calling get_offsets() to return the default zeros case, and then internally checking the None/default case in get_datalim() which is the only place where this information is needed.
@meeseeksdev backport to v3.5.x |
Owee, I'm MrMeeseeks, Look at me. There seem to be a conflict, please backport manually. Here are approximate instructions:
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 If these instructions are inaccurate, feel free to suggest an improvement. |
…talim (alternative)
…on-v3.5.x Backport PR #22946: FIX: Handle no-offsets in collection datalim
PR Summary
Alternative to #22945
This keeps the None-default case in
self._offsets
and then transforms to the zeros for default math in theget_offsets()
method. This is necessary to handle the (0, 0) offset case that is desired and distinguishing that from the initial empty offset of None. In particular, this is necessary for the non-transData IdentityTransform passed in during tight_layout calculations.closes #22921
PR Checklist
Tests and Styling
pytest
passes).flake8-docstrings
and runflake8 --docstring-convention=all
).Documentation
doc/users/next_whats_new/
(follow instructions in README.rst there).doc/api/next_api_changes/
(follow instructions in README.rst there).