Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 68dad00

Browse filesBrowse files
author
Yi Wei
committed
check if the mask is unwritable
1 parent a9d9eaf commit 68dad00
Copy full SHA for 68dad00

File tree

Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed
Filter options
Expand file treeCollapse file tree

1 file changed

+7
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+7-2Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5740,6 +5740,9 @@ def imshow(self, X, cmap=None, norm=None, *, aspect=None,
57405740
self.add_image(im)
57415741
return im
57425742

5743+
def _is_unwritable(self, c):
5744+
return np.ma.is_masked(c) and not c.mask.flags.writeable
5745+
57435746
def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
57445747
# - create X and Y if not present;
57455748
# - reshape X and Y as needed if they are 1-D;
@@ -5764,7 +5767,8 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
57645767
else:
57655768
X, Y = np.meshgrid(np.arange(ncols + 1), np.arange(nrows + 1))
57665769
shading = 'flat'
5767-
C = cbook.safe_masked_invalid(C, copy=True)
5770+
copy = self._is_unwritable(C)
5771+
C = cbook.safe_masked_invalid(C, copy=copy)
57685772
return X, Y, C, shading
57695773

57705774
if len(args) == 3:
@@ -5853,7 +5857,8 @@ def _interp_grid(X):
58535857
Y = _interp_grid(Y.T).T
58545858
shading = 'flat'
58555859

5856-
C = cbook.safe_masked_invalid(C, copy=True)
5860+
copy = self._is_unwritable(C)
5861+
C = cbook.safe_masked_invalid(C, copy=copy)
58575862
return X, Y, C, shading
58585863

58595864
@_preprocess_data()

0 commit comments

Comments
0 (0)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.