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

Skip to content

Commit 4cdf482

Browse files
committed
Let TransformedPatchPath inherit most functionality from TransformedPath.
1 parent f0593a6 commit 4cdf482

File tree

1 file changed

+8
-20
lines changed

1 file changed

+8
-20
lines changed

lib/matplotlib/transforms.py

Lines changed: 8 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -2815,37 +2815,25 @@ class TransformedPatchPath(TransformedPath):
28152815
`~.patches.Patch`. This cached copy is automatically updated when the
28162816
non-affine part of the transform or the patch changes.
28172817
"""
2818+
28182819
def __init__(self, patch):
28192820
"""
28202821
Parameters
28212822
----------
28222823
patch : `~.patches.Patch`
28232824
"""
2824-
TransformNode.__init__(self)
2825-
2826-
transform = patch.get_transform()
2825+
# Defer to TransformedPath.__init__.
2826+
super().__init__(patch.get_path(), patch.get_transform())
28272827
self._patch = patch
2828-
self._transform = transform
2829-
self.set_children(transform)
2830-
self._path = patch.get_path()
2831-
self._transformed_path = None
2832-
self._transformed_points = None
28332828

28342829
def _revalidate(self):
28352830
patch_path = self._patch.get_path()
2836-
# Only recompute if the invalidation includes the non_affine part of
2837-
# the transform, or the Patch's Path has changed.
2838-
if (self._transformed_path is None or self._path != patch_path or
2839-
(self._invalid & self.INVALID_NON_AFFINE ==
2840-
self.INVALID_NON_AFFINE)):
2831+
# Force invalidation if the patch path changed; otherwise, let base
2832+
# class check invalidation.
2833+
if patch_path != self._path:
28412834
self._path = patch_path
2842-
self._transformed_path = \
2843-
self._transform.transform_path_non_affine(patch_path)
2844-
self._transformed_points = \
2845-
Path._fast_from_codes_and_verts(
2846-
self._transform.transform_non_affine(patch_path.vertices),
2847-
None, patch_path)
2848-
self._invalid = 0
2835+
self._transformed_path = None
2836+
super()._revalidate()
28492837

28502838

28512839
def nonsingular(vmin, vmax, expander=0.001, tiny=1e-15, increasing=True):

0 commit comments

Comments
 (0)