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

Skip to content

Commit 17d8bf0

Browse files
authored
Add test_fill in test_datetime.py (#27401)
* added a test for fill in test_datetime.py * Removed saving the picture from test code. * reverted .gitignore changes I had added my virtual environment to gitignore and pushed it. Reverted back before pull request * added seed
1 parent 161d47b commit 17d8bf0

File tree

1 file changed

+24
-3
lines changed

1 file changed

+24
-3
lines changed

lib/matplotlib/tests/test_datetime.py

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -284,11 +284,32 @@ def test_eventplot(self):
284284
fig, ax = plt.subplots()
285285
ax.eventplot(...)
286286

287-
@pytest.mark.xfail(reason="Test for fill not written yet")
288287
@mpl.style.context("default")
289288
def test_fill(self):
290-
fig, ax = plt.subplots()
291-
ax.fill(...)
289+
mpl.rcParams["date.converter"] = "concise"
290+
fig, (ax1, ax2, ax3, ax4) = plt.subplots(4, 1, layout="constrained")
291+
292+
np.random.seed(19680801)
293+
294+
x_base_date = datetime.datetime(2023, 1, 1)
295+
x_dates = [x_base_date]
296+
for _ in range(1, 5):
297+
x_base_date += datetime.timedelta(days=np.random.randint(1, 5))
298+
x_dates.append(x_base_date)
299+
300+
y_base_date = datetime.datetime(2023, 1, 1)
301+
y_dates = [y_base_date]
302+
for _ in range(1, 5):
303+
y_base_date += datetime.timedelta(days=np.random.randint(1, 5))
304+
y_dates.append(y_base_date)
305+
306+
x_values = np.random.rand(5) * 5
307+
y_values = np.random.rand(5) * 5 - 2
308+
309+
ax1.fill(x_dates, y_values)
310+
ax2.fill(x_values, y_dates)
311+
ax3.fill(x_values, y_values)
312+
ax4.fill(x_dates, y_dates)
292313

293314
@pytest.mark.xfail(reason="Test for fill_between not written yet")
294315
@mpl.style.context("default")

0 commit comments

Comments
 (0)