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

Skip to content

Commit c9244df

Browse files
committed
BUG : Add validation for masked arrays in _revalidate
Ensure that transforms that return masked arrays have the arrays filled with nan Improved the code readability.
1 parent 24bdc37 commit c9244df

File tree

1 file changed

+19
-8
lines changed

1 file changed

+19
-8
lines changed

lib/matplotlib/transforms.py

Lines changed: 19 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2615,14 +2615,25 @@ def __init__(self, path, transform):
26152615
self._transformed_points = None
26162616

26172617
def _revalidate(self):
2618-
# only recompute if the invalidation includes the non_affine part of the transform
2619-
if ((self._invalid & self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
2620-
or self._transformed_path is None):
2621-
self._transformed_path = \
2622-
self._transform.transform_path_non_affine(self._path)
2623-
self._transformed_points = \
2624-
Path._fast_from_codes_and_verts(self._transform.transform_non_affine(self._path.vertices),
2625-
None, {'interpolation_steps': self._path._interpolation_steps})
2618+
# only recompute if the invalidation includes
2619+
# the non_affine part of the transform
2620+
if ((self._invalid &
2621+
self.INVALID_NON_AFFINE == self.INVALID_NON_AFFINE)
2622+
or self._transformed_path is None):
2623+
2624+
tpath = self._transform.transform_path_non_affine(self._path)
2625+
self._transformed_path = tpath
2626+
2627+
x = self._transform.transform_non_affine(self._path.vertices)
2628+
if ma.isMaskedArray(x):
2629+
x = x.astype(np.float_).filled(np.nan)
2630+
2631+
tpts = Path._fast_from_codes_and_verts(verts=x, codes=None,
2632+
internals={'interpolation_steps':
2633+
self._path._interpolation_steps})
2634+
2635+
self._transformed_points = tpts
2636+
26262637
self._invalid = 0
26272638

26282639
def get_transformed_points_and_affine(self):

0 commit comments

Comments
 (0)