Skip to content

Commit c93223d

Browse files
committed
wireframe3d raise when both cstride and rstride are 0
1 parent bf3ccb3 commit c93223d

File tree

2 files changed

+18
-1
lines changed

2 files changed

+18
-1
lines changed

lib/mpl_toolkits/mplot3d/axes3d.py

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1765,6 +1765,9 @@ def plot_wireframe(self, X, Y, Z, *args, **kwargs):
17651765
else:
17661766
cii = []
17671767

1768+
if rstride == 0 and cstride == 0:
1769+
raise ValueError("Either rstride or cstride must be non zero")
1770+
17681771
# If the inputs were empty, then just
17691772
# reset everything.
17701773
if Z.size == 0 :

lib/mpl_toolkits/tests/test_mplot3d.py

Lines changed: 15 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1+
import sys
2+
import nose
3+
from nose.tools import assert_raises
14
from mpl_toolkits.mplot3d import Axes3D, axes3d
25
from matplotlib import cm
3-
from matplotlib.testing.decorators import image_comparison
6+
from matplotlib.testing.decorators import image_comparison, cleanup
47
import matplotlib.pyplot as plt
58
import numpy as np
69

@@ -189,6 +192,17 @@ def test_wireframe3dzerorstride():
189192
X, Y, Z = axes3d.get_test_data(0.05)
190193
ax.plot_wireframe(X, Y, Z, rstride=0, cstride=10)
191194

195+
@cleanup
196+
def test_wireframe3dzerostrideraises():
197+
if sys.version_info[:2] < (2, 7):
198+
raise nose.SkipTest("assert_raises as context manager "
199+
"not supported with Python < 2.7")
200+
fig = plt.figure()
201+
ax = fig.add_subplot(111, projection='3d')
202+
X, Y, Z = axes3d.get_test_data(0.05)
203+
with assert_raises(ValueError):
204+
ax.plot_wireframe(X, Y, Z, rstride=0, cstride=0)
205+
192206
@image_comparison(baseline_images=['quiver3d'], remove_text=True)
193207
def test_quiver3d():
194208
fig = plt.figure()

0 commit comments

Comments
 (0)