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 6881a9d

Browse filesBrowse files
WeatherGodmdboom
authored andcommitted
Apply asanyarray to arguments for pcolor and family
1 parent 0a7a41d commit 6881a9d
Copy full SHA for 6881a9d

File tree

Expand file treeCollapse file tree

2 files changed

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

2 files changed

+17
-2
lines changed

‎lib/matplotlib/axes/_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/axes/_axes.py
+2-2Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4976,7 +4976,7 @@ def _pcolorargs(funcname, *args, **kw):
49764976
allmatch = kw.pop("allmatch", False)
49774977

49784978
if len(args) == 1:
4979-
C = args[0]
4979+
C = np.asanyarray(args[0])
49804980
numRows, numCols = C.shape
49814981
if allmatch:
49824982
X, Y = np.meshgrid(np.arange(numCols), np.arange(numRows))
@@ -4986,7 +4986,7 @@ def _pcolorargs(funcname, *args, **kw):
49864986
return X, Y, C
49874987

49884988
if len(args) == 3:
4989-
X, Y, C = args
4989+
X, Y, C = [np.asanyarray(a) for a in args]
49904990
numRows, numCols = C.shape
49914991
else:
49924992
raise TypeError(

‎lib/matplotlib/tests/test_axes.py

Copy file name to clipboardExpand all lines: lib/matplotlib/tests/test_axes.py
+15Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -738,6 +738,21 @@ def test_symlog2():
738738
ax.set_ylim(-0.1, 0.1)
739739

740740

741+
@cleanup
742+
def test_pcolorargs():
743+
# Smoketest to catch issue found in gh:5205
744+
x = [-1.5, -1.0, -0.5, 0.0, 0.5, 1.0, 1.5]
745+
y = [-1.5, -1.25, -1.0, -0.75, -0.5, -0.25, 0,
746+
0.25, 0.5, 0.75, 1.0, 1.25, 1.5]
747+
X, Y = np.meshgrid(x, y)
748+
Z = np.hypot(X, Y)
749+
750+
plt.pcolor(Z)
751+
plt.pcolor(list(Z))
752+
plt.pcolor(x, y, Z)
753+
plt.pcolor(X, Y, list(Z))
754+
755+
741756
@image_comparison(baseline_images=['pcolormesh'], remove_text=True)
742757
def test_pcolormesh():
743758
n = 12

0 commit comments

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