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

Skip to content

Commit 24bdc37

Browse files
committed
BUG : fix optimized path transforms
Fixes #3998. The issue is that some transfroms sometimes returned masked arrays from `transform_non_affine` (ex Log10transform). The `Path` constructor fills masked arrays to full arrays with `np.nan`, but the `_fast_from_codes_and_verts` does not (as it assumes the verts have been fully validated on the way in). This adds the maskedarray -> np.nan filled array normalization into `transform_path_non_affine`.
1 parent 8b5d6af commit 24bdc37

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

lib/matplotlib/transforms.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1300,7 +1300,7 @@ def transform(self, values):
13001300

13011301
# Convert the result back to the shape of the input values.
13021302
if ndim == 0:
1303-
assert not np.ma.is_masked(res) # just to be on the safe side
1303+
assert not np.ma.is_masked(res) # just to be on the safe side
13041304
return res[0, 0]
13051305
if ndim == 1:
13061306
return res.reshape(-1)
@@ -1412,6 +1412,8 @@ def transform_path_non_affine(self, path):
14121412
``transform_path_affine(transform_path_non_affine(values))``.
14131413
"""
14141414
x = self.transform_non_affine(path.vertices)
1415+
if ma.isMaskedArray(x):
1416+
x = x.astype(np.float_).filled(np.nan)
14151417
return Path._fast_from_codes_and_verts(x, path.codes,
14161418
{'interpolation_steps': path._interpolation_steps})
14171419

0 commit comments

Comments
 (0)