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

Skip to content

Commit 24842ec

Browse files
authored
Add smoke test for Axes.barbs in test_datetime.py (#27331)
* added smoke test for Axes.barbs in test_datetime.py * changed to use deterministic data
1 parent fcf57fe commit 24842ec

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
@@ -146,11 +146,29 @@ def test_bar_label(self):
146146
fig, ax = plt.subplots()
147147
ax.bar_label(...)
148148

149-
@pytest.mark.xfail(reason="Test for barbs not written yet")
150149
@mpl.style.context("default")
151150
def test_barbs(self):
152-
fig, ax = plt.subplots()
153-
ax.barbs(...)
151+
plt.rcParams["date.converter"] = 'concise'
152+
153+
start_date = datetime.datetime(2022, 2, 8, 22)
154+
dates = [start_date + datetime.timedelta(hours=i) for i in range(12)]
155+
156+
numbers = np.sin(np.linspace(0, 2 * np.pi, 12))
157+
158+
u = np.ones(12) * 10
159+
v = np.arange(0, 120, 10)
160+
161+
fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 6))
162+
163+
axes[0].barbs(dates, numbers, u, v, length=7)
164+
axes[0].set_title('Datetime vs. Numeric Data')
165+
axes[0].set_xlabel('Datetime')
166+
axes[0].set_ylabel('Numeric Data')
167+
168+
axes[1].barbs(numbers, dates, u, v, length=7)
169+
axes[1].set_title('Numeric vs. Datetime Data')
170+
axes[1].set_xlabel('Numeric Data')
171+
axes[1].set_ylabel('Datetime')
154172

155173
@mpl.style.context("default")
156174
def test_barh(self):

0 commit comments

Comments
 (0)