Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit f7e74da

Browse files
Merge pull request #27024 from kots14/axes-contourf-unit-test-for-issue-26864
Add test_contourf in test_datetime.py
2 parents dfdb37a + 5881a90 commit f7e74da

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
@@ -123,11 +123,29 @@ def test_contour(self):
123123
fig, ax = plt.subplots()
124124
ax.contour(...)
125125

126-
@pytest.mark.xfail(reason="Test for contourf not written yet")
127126
@mpl.style.context("default")
128127
def test_contourf(self):
129-
fig, ax = plt.subplots()
130-
ax.contourf(...)
128+
mpl.rcParams["date.converter"] = "concise"
129+
range_threshold = 10
130+
fig, (ax1, ax2, ax3) = plt.subplots(3, 1, layout="constrained")
131+
132+
x_dates = np.array(
133+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
134+
)
135+
y_dates = np.array(
136+
[datetime.datetime(2023, 10, delta) for delta in range(1, range_threshold)]
137+
)
138+
x_ranges = np.array(range(1, range_threshold))
139+
y_ranges = np.array(range(1, range_threshold))
140+
141+
X_dates, Y_dates = np.meshgrid(x_dates, y_dates)
142+
X_ranges, Y_ranges = np.meshgrid(x_ranges, y_ranges)
143+
144+
Z_ranges = np.cos(X_ranges / 4) + np.sin(Y_ranges / 4)
145+
146+
ax1.contourf(X_dates, Y_dates, Z_ranges)
147+
ax2.contourf(X_dates, Y_ranges, Z_ranges)
148+
ax3.contourf(X_ranges, Y_dates, Z_ranges)
131149

132150
@pytest.mark.xfail(reason="Test for errorbar not written yet")
133151
@mpl.style.context("default")

0 commit comments

Comments
 (0)