Skip to content

Caching the results of Transform.transform_path for non-affine transforms #723

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
merged 9 commits into from
Jun 8, 2012
Prev Previous commit
Next Next commit
Fixed broken handling of WrappedTransform
  • Loading branch information
Phil Elson authored and pelson committed Jun 7, 2012
commit c0884772332c011429a604d0ab0d04ab2f41a02c
14 changes: 9 additions & 5 deletions lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1293,11 +1293,11 @@ def _set(self, child):
self.transform_path_non_affine = child.transform_path_non_affine
self.get_affine = child.get_affine
self.inverted = child.inverted
self.is_affine = child.is_affine
self.get_matrix = child.get_matrix

def __eq__(self, other):
return self._child == other
# note we do not wrap other properties here since the transform's
# child can be changed with WrappedTransform.set and so checking
# is_affine and other such properties may be dangerous.

def set(self, child):
"""
Expand Down Expand Up @@ -2044,9 +2044,13 @@ def composite_transform_factory(a, b):

c = a + b
"""
if a == IdentityTransform():
# check to see if any of a or b are IdentityTransforms. Note we
# do not use equality here since we may have wrapped transforms
# which are currently equal to Identity, but since wrapped transforms
# are mutable, they may not always be equal.
if isinstance(a, IdentityTransform):
return b
elif b == IdentityTransform():
elif isinstance(b, IdentityTransform):
return a
elif a.is_affine and b.is_affine:
return CompositeAffine2D(a, b)
Expand Down