-
-
Notifications
You must be signed in to change notification settings - Fork 7.9k
Changed Bbox.transformed to support more general affine transformations. #27152
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
base: main
Are you sure you want to change the base?
Changed Bbox.transformed to support more general affine transformations. #27152
Conversation
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.
Thank you for opening your first PR into Matplotlib!
If you have not heard from us in a week or so, please leave a new comment below and that should bring it to our attention. Most of our reviewers are volunteers and sometimes things fall through the cracks.
You can also join us on gitter for real-time discussion.
For details on testing, writing docs, and our review process, please see the developer guide
We strive to be a welcoming and open project. Please follow our Code of Conduct.
I think this is right, but shocking this wasn't tested before. Can you add some tests to test_transforms.py so we don't break this? |
I think I agree that the implementation needs to be updated. However, there has been recent discussion regarding deprecating Currently corners is only used internally in I suppose there is also a broader question of non-affine transforms... while for Affine transforms, I think it should be true that the corners will define the total extent, that is not generically true, but I don't think we have the ability to guarantee accuracy of this method for all transforms... (Take, for example a geographic transform where the poles end up degenerate, and so the corners of the bounding box end up with just a sliver rather than encompasing the whole transformed shape...) |
See also #12059, though. |
@jklymak @ksunden @anntzer, thanks for the feedback! I'm a big fan of the matplotlib package, so thanks for the work you do. My sense is that However, I think the most interesting thing, here, is to agree on what Supporting affine transformations seems to be a reasonable line to draw. I think the argument is twofold: (1) an affine transform will map segments to segments and (2) an affine transform will preserve convexity. The implication is that you only need to consider the transformation of the corners and their corresponding extents to correctly recover the bounding box under the transformation. Another level of generality would be to support continuous transformations. The idea here is that you want to preserve topologies: if the transformation avoids cutting or piercing the domain, then the only thing that needs consideration is the boundary of the domain. This could be addressed by inserting points along each edge of the box and transforming these newly introduced points along with the corners. One might hazard a guarantee on accuracy with a multiresolution approach. That is, if the number of points along each edge is N, and we compute something like the boundary length under the transformation; and we do the same where the number of points along each edge is 2*N; and if these numbers agree within some tolerance, then we can have some confidence that we have correctly transformed the original boundary. I haven't given much thought to the more general cases although I would expect the complexity of a solution to increase; nor is it clear that that there's a demonstrable need for it. Going back to the continuous case, a multiresolution solution doesn't seem well aligned with the idea that All told, I think the affine case is a good target with one caveat: I don't want to throw any exceptions on the |
Bumping the thread for feedback on this PR. The tl;dr proposal: support affine transforms in |
PR summary
The original Bbox.transformed method does not work correctly with general affine transformations.
Relevant issue 27151
This PR closes #27151.
PR checklist