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 4435838

Browse filesBrowse files
author
Yi Wei
committed
FIX: pcolor writing to read-only input mask
1 parent ae723ba commit 4435838
Copy full SHA for 4435838

File tree

Expand file treeCollapse file tree

2 files changed

+10
-4
lines changed
Filter options
Expand file treeCollapse file tree

2 files changed

+10
-4
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+1-1Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5773,7 +5773,7 @@ def _pcolorargs(self, funcname, *args, shading='auto', **kwargs):
57735773
# unit conversion allows e.g. datetime objects as axis values
57745774
X, Y = args[:2]
57755775
X, Y = self._process_unit_info([("x", X), ("y", Y)], kwargs)
5776-
X, Y = [cbook.safe_masked_invalid(a) for a in [X, Y]]
5776+
X, Y = [cbook.safe_masked_invalid(a, copy=True) for a in [X, Y]]
57775777

57785778
if funcname == 'pcolormesh':
57795779
if np.ma.is_masked(X) or np.ma.is_masked(Y):

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+9-3Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1507,11 +1507,17 @@ def test_pcolorargs_with_read_only():
15071507
y = np.linspace(0, 1, 10)
15081508
X, Y = np.meshgrid(x, y)
15091509
Z = np.sin(2 * np.pi * X) * np.cos(2 * np.pi * Y)
1510-
Zmask = np.broadcast_to([True, False] * 5, Z.shape)
1511-
assert Zmask.flags.writeable is False
1512-
masked_Z = np.ma.array(Z, mask=Zmask)
1510+
mask = np.broadcast_to([True, False] * 5, Z.shape)
1511+
assert mask.flags.writeable is False
1512+
masked_Z = np.ma.array(Z, mask=mask)
15131513
plt.pcolormesh(X, Y, masked_Z)
15141514

1515+
masked_X = np.ma.array(X, mask=mask)
1516+
masked_Y = np.ma.array(Y, mask=mask)
1517+
with pytest.warns(UserWarning,
1518+
match='are not monotonically increasing or decreasing'):
1519+
plt.pcolor(masked_X, masked_Y, masked_Z)
1520+
15151521

15161522
@check_figures_equal(extensions=["png"])
15171523
def test_pcolornearest(fig_test, fig_ref):

0 commit comments

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