Skip to content

Commit 92cc8f5

Browse files
authored
Add test_contour under test_datetime.py (matplotlib#27013)
* Add test_contour matplotlib#26864 * Add test_contour matplotlib#26864 Modify test_contour matplotlib#26864 * Removed test_cohere and repetitive tests
1 parent 6c953e8 commit 92cc8f5

File tree

1 file changed

+21
-3
lines changed

1 file changed

+21
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 21 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -265,11 +265,29 @@ def test_clabel(self):
265265
fig, ax = plt.subplots()
266266
ax.clabel(...)
267267

268-
@pytest.mark.xfail(reason="Test for contour not written yet")
269268
@mpl.style.context("default")
270269
def test_contour(self):
271-
fig, ax = plt.subplots()
272-
ax.contour(...)
270+
mpl.rcParams["date.converter"] = "concise"
271+
range_threshold = 10
272+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout="constrained")
273+
274+
x_dates = np.array(
275+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
276+
)
277+
y_dates = np.array(
278+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
279+
)
280+
x_ranges = np.array(range(1, range_threshold))
281+
y_ranges = np.array(range(1, range_threshold))
282+
283+
X_dates, Y_dates = np.meshgrid(x_dates, y_dates)
284+
X_ranges, Y_ranges = np.meshgrid(x_ranges, y_ranges)
285+
286+
Z_ranges = np.cos(X_ranges / 4) + np.sin(Y_ranges / 4)
287+
288+
ax1.contour(X_dates, Y_dates, Z_ranges)
289+
ax2.contour(X_dates, Y_ranges, Z_ranges)
290+
ax3.contour(X_ranges, Y_dates, Z_ranges)
273291

274292
@mpl.style.context("default")
275293
def test_contourf(self):

0 commit comments

Comments
 (0)