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

Skip to content

Commit 4b1b9d8

Browse files
committed
TST: add smoke test for pcolormesh + pandas + dates
1 parent 7d69aca commit 4b1b9d8

File tree

1 file changed

+30
-0
lines changed

1 file changed

+30
-0
lines changed

lib/matplotlib/tests/test_axes.py

Lines changed: 30 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1660,6 +1660,36 @@ def test_boxplot_dates_pandas(pd):
16601660
plt.boxplot(data, positions=years)
16611661

16621662

1663+
def test_pcolor_regression(pd):
1664+
from pandas.plotting import (
1665+
register_matplotlib_converters,
1666+
deregister_matplotlib_converters,
1667+
)
1668+
1669+
fig = plt.figure()
1670+
ax = fig.add_subplot(111)
1671+
1672+
times = [datetime.datetime(2021, 1, 1)]
1673+
while len(times) < 7:
1674+
times.append(times[-1] + datetime.timedelta(seconds=120))
1675+
1676+
y_vals = np.arange(5)
1677+
1678+
time_axis, y_axis = np.meshgrid(times, y_vals)
1679+
shape = (len(y_vals) - 1, len(times) - 1)
1680+
z_data = np.arange(shape[0] * shape[1])
1681+
1682+
z_data.shape = shape
1683+
try:
1684+
register_matplotlib_converters()
1685+
1686+
im = ax.pcolormesh(time_axis, y_axis, z_data)
1687+
# make sure this does not raise!
1688+
fig.canvas.draw()
1689+
finally:
1690+
deregister_matplotlib_converters()
1691+
1692+
16631693
def test_bar_pandas(pd):
16641694
# Smoke test for pandas
16651695
df = pd.DataFrame(

0 commit comments

Comments
 (0)