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

Skip to content
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 @@ def contains_branch_seperately(self, other_transform):
'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 @@ def _iter_break_from_left_to_right(self):
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 '
'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