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

Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 20 additions & 2 deletions lib/matplotlib/tests/test_datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@

import matplotlib.pyplot as plt
import matplotlib as mpl
import matplotlib.dates as dt


class TestDatetimePlotting:
Expand Down Expand Up @@ -545,11 +546,28 @@ def test_pcolor(self):
fig, ax = plt.subplots()
ax.pcolor(...)

@pytest.mark.xfail(reason="Test for pcolorfast not written yet")
@mpl.style.context("default")
def test_pcolorfast(self):
np.random.seed(19680801)

'''
Directly inputting either datetime.datetime or numpy.datetime64
without using date2num() seems to always generate compile errors for pcolorfast().
I have used date2num() to ensure that the graph prints correctly
despite that such operations may defy the purpose of conducting such tests.
'''
basedate_x = datetime.datetime(2023, 12, 6, 1, 30, 30)
basedate_y = datetime.datetime(2024, 5, 5, 12, 15, 45)
dates_x = [dt.date2num(basedate_x + datetime.timedelta(days=1*i, hours=6*i, minutes=20*i)) for i in range(10)]
dates_y = [dt.date2num(basedate_y + datetime.timedelta(days=1*i, hours=8*i, minutes=30*i)) for i in range(10)]
data = np.random.rand(0, 100)

fig, ax = plt.subplots()
ax.pcolorfast(...)
pc = ax.pcolorfast(dates_x, dates_y, data)

ax.set_xlabel('Sample datetime')
ax.set_ylabel('Sample data')
ax.set_title('Sample test case for pcolorfast()')

@pytest.mark.xfail(reason="Test for pcolormesh not written yet")
@mpl.style.context("default")
Expand Down