Fix CompositeGenericTransform.contains_branch_separately ignoring first child#32109
Fix CompositeGenericTransform.contains_branch_separately ignoring first child#32109AnishPatel526 wants to merge 1 commit into
Conversation
|
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. We also ask that you please finish addressing any review comments on this PR and wait for it to be merged (or closed) before opening a new one, as it can be a valuable learning experience to go through the review process. You can also join us on discourse chat 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. |
Fix CompositeGenericTransform.contains_branch_separately ignoring the first child (closes #32099)
PR summary
CompositeGenericTransform.contains_branch_separatelyonly inspected thesecond (suffix) child,
self._b, so any branch located in the first childself._a— or one that spans the boundary between the two children — wasreported as absent. This made the per-dimension result inconsistent with
contains_branch, which correctly detects such branches.Reproduction (matplotlib 3.10.9)
Fix
Query the suffix child first (so a blended child can still report distinct
per-dimension results), and when it does not already contain the branch in both
dimensions, fall back to the whole-transform
contains_branchcheck. A branchfound that way is a complete suffix of the composite and therefore applies to
both dimensions.
A naive alternative — ORing
self._aandself._b's separate results — doesnot work, because a branch that straddles the split point (e.g.
subsetabove) is a suffix of neither child individually; only the whole-transform
check catches it.
After the fix the reproduction returns
(True, True), matchingcontains_branch.Behaviour preserved
test_contains_branchcasestack_blend.contains_branch_separately(...)still returns
(False, True).(False, False)— no over-reporting.Tests
Extended
TestBasicTransform.test_contains_branchinlib/matplotlib/tests/test_transforms.pywith cases for a branch in the firstchild, a branch spanning the child boundary, and a non-branch. These fail on
mainand pass with this change.AI Disclosure
AI assistance was used to investigate the codebase and draft this change and
its tests; the logic was verified manually against the released build.
PR checklist