Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 8ccd2ee

Browse files
authored
Merge pull request #28490 from meeseeksmachine/auto-backport-of-pr-28486-on-v3.9.x
Backport PR #28486 on branch v3.9.x (Fix CompositeGenericTransform.contains_branch_seperately)
2 parents 51decc5 + b7d25c4 commit 8ccd2ee

File tree

2 files changed

+17
-1
lines changed

2 files changed

+17
-1
lines changed

lib/matplotlib/tests/test_transforms.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -667,6 +667,13 @@ def test_contains_branch(self):
667667

668668
assert not self.stack1.contains_branch(self.tn1 + self.ta2)
669669

670+
blend = mtransforms.BlendedGenericTransform(self.tn2, self.stack2)
671+
x, y = blend.contains_branch_seperately(self.stack2_subset)
672+
stack_blend = self.tn3 + blend
673+
sx, sy = stack_blend.contains_branch_seperately(self.stack2_subset)
674+
assert x is sx is False
675+
assert y is sy is True
676+
670677
def test_affine_simplification(self):
671678
# tests that a transform stack only calls as much is absolutely
672679
# necessary "non-affine" allowing the best possible optimization with

lib/matplotlib/transforms.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1423,7 +1423,7 @@ def contains_branch_seperately(self, other_transform):
14231423
'transforms with 2 output dimensions')
14241424
# for a non-blended transform each separate dimension is the same, so
14251425
# just return the appropriate shape.
1426-
return [self.contains_branch(other_transform)] * 2
1426+
return (self.contains_branch(other_transform), ) * 2
14271427

14281428
def __sub__(self, other):
14291429
"""
@@ -2404,6 +2404,15 @@ def _iter_break_from_left_to_right(self):
24042404
for left, right in self._b._iter_break_from_left_to_right():
24052405
yield self._a + left, right
24062406

2407+
def contains_branch_seperately(self, other_transform):
2408+
# docstring inherited
2409+
if self.output_dims != 2:
2410+
raise ValueError('contains_branch_seperately only supports '
2411+
'transforms with 2 output dimensions')
2412+
if self == other_transform:
2413+
return (True, True)
2414+
return self._b.contains_branch_seperately(other_transform)
2415+
24072416
depth = property(lambda self: self._a.depth + self._b.depth)
24082417
is_affine = property(lambda self: self._a.is_affine and self._b.is_affine)
24092418
is_separable = property(

0 commit comments

Comments
 (0)