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

Skip to content

Backport PR #28486 on branch v3.9.x (Fix CompositeGenericTransform.contains_branch_seperately) #28490

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

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions lib/matplotlib/tests/test_transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -667,6 +667,13 @@ def test_contains_branch(self):

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

blend = mtransforms.BlendedGenericTransform(self.tn2, self.stack2)
x, y = blend.contains_branch_seperately(self.stack2_subset)
stack_blend = self.tn3 + blend
sx, sy = stack_blend.contains_branch_seperately(self.stack2_subset)
assert x is sx is False
assert y is sy is True

def test_affine_simplification(self):
# tests that a transform stack only calls as much is absolutely
# necessary "non-affine" allowing the best possible optimization with
Expand Down
11 changes: 10 additions & 1 deletion lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1423,7 +1423,7 @@
'transforms with 2 output dimensions')
# for a non-blended transform each separate dimension is the same, so
# just return the appropriate shape.
return [self.contains_branch(other_transform)] * 2
return (self.contains_branch(other_transform), ) * 2

def __sub__(self, other):
"""
Expand Down Expand Up @@ -2404,6 +2404,15 @@
for left, right in self._b._iter_break_from_left_to_right():
yield self._a + left, right

def contains_branch_seperately(self, other_transform):
# docstring inherited
if self.output_dims != 2:
raise ValueError('contains_branch_seperately only supports '

Check warning on line 2410 in lib/matplotlib/transforms.py

View check run for this annotation

Codecov / codecov/patch

lib/matplotlib/transforms.py#L2410

Added line #L2410 was not covered by tests
'transforms with 2 output dimensions')
if self == other_transform:
return (True, True)
return self._b.contains_branch_seperately(other_transform)

depth = property(lambda self: self._a.depth + self._b.depth)
is_affine = property(lambda self: self._a.is_affine and self._b.is_affine)
is_separable = property(
Expand Down
Loading