Skip to content
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

Replace getmask with getmaskarray #24118

Draft
wants to merge 1 commit into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
13 changes: 5 additions & 8 deletions lib/matplotlib/colors.py
Original file line number Diff line number Diff line change
Expand Up @@ -1302,9 +1302,8 @@ def process_value(value):
dtype = np.promote_types(dtype, np.float32)
# ensure data passed in as an ndarray subclass are interpreted as
# an ndarray. See issue #6622.
mask = np.ma.getmask(value)
data = np.asarray(value)
result = np.ma.array(data, mask=mask, dtype=dtype, copy=True)
result = np.ma.array(np.asarray(value), mask=np.ma.getmaskarray(value),
dtype=dtype, copy=True)
return result, is_scalar

def __call__(self, value, clip=None):
Expand Down Expand Up @@ -1341,9 +1340,8 @@ def __call__(self, value, clip=None):
raise ValueError("minvalue must be less than or equal to maxvalue")
else:
if clip:
mask = np.ma.getmask(result)
result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax),
mask=mask)
mask=np.ma.getmaskarray(result))
# ma division is very slow; we can take a shortcut
resdat = result.data
resdat -= vmin
Expand Down Expand Up @@ -1459,7 +1457,7 @@ def __call__(self, value, clip=None):
result = np.ma.masked_array(
np.interp(result, [self.vmin, self.vcenter, self.vmax],
[0, 0.5, 1], left=-np.inf, right=np.inf),
mask=np.ma.getmask(result))
mask=np.ma.getmaskarray(result))
if is_scalar:
result = np.atleast_1d(result)[0]
return result
Expand Down Expand Up @@ -1873,9 +1871,8 @@ def __call__(self, value, clip=None):
result.fill(0)
else:
if clip:
mask = np.ma.getmask(result)
result = np.ma.array(np.clip(result.filled(vmax), vmin, vmax),
mask=mask)
mask=np.ma.getmaskarray(result))
resdat = result.data
resdat -= vmin
resdat[resdat < 0] = 0
Expand Down
2 changes: 1 addition & 1 deletion lib/matplotlib/transforms.py
Original file line number Diff line number Diff line change
Expand Up @@ -1849,7 +1849,7 @@ def transform_affine(self, points):
mtx = self.get_matrix()
if isinstance(points, np.ma.MaskedArray):
tpoints = affine_transform(points.data, mtx)
return np.ma.MaskedArray(tpoints, mask=np.ma.getmask(points))
return np.ma.MaskedArray(tpoints, mask=np.ma.getmaskarray(points))
return affine_transform(points, mtx)

if DEBUG:
Expand Down