From 38f4332b6eb923fd90e2fbc88c5dfc517cc81c0e Mon Sep 17 00:00:00 2001 From: Elisa Heckelmann Date: Wed, 15 Nov 2023 16:24:40 +0100 Subject: [PATCH 1/2] added smoke test for Axes.barbs in test_datetime.py --- lib/matplotlib/tests/test_datetime.py | 24 +++++++++++++++++++++--- 1 file changed, 21 insertions(+), 3 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index b19124a1b764..44d04801a3c5 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -146,11 +146,29 @@ def test_bar_label(self): fig, ax = plt.subplots() ax.bar_label(...) - @pytest.mark.xfail(reason="Test for barbs not written yet") @mpl.style.context("default") def test_barbs(self): - fig, ax = plt.subplots() - ax.barbs(...) + plt.rcParams["date.converter"] = 'concise' + + start_date = datetime.datetime.now() + dates = [start_date + datetime.timedelta(hours=i) for i in range(12)] + + numbers = np.random.rand(len(dates)) + + u = np.random.rand(len(dates)) + v = np.random.rand(len(dates)) * 100 + + fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 6)) + + axes[0].barbs(dates, numbers, u, v, length=7) + axes[0].set_title('Datetime vs. Numeric Data') + axes[0].set_xlabel('Datetime') + axes[0].set_ylabel('Numeric Data') + + axes[1].barbs(numbers, dates, u, v, length=7) + axes[1].set_title('Numeric vs. Datetime Data') + axes[1].set_xlabel('Numeric Data') + axes[1].set_ylabel('Datetime') @mpl.style.context("default") def test_barh(self): From 5e98fd7ce9935b7e23ff263a564ae0da0bd73f37 Mon Sep 17 00:00:00 2001 From: Elisa Heckelmann Date: Wed, 15 Nov 2023 17:51:00 +0100 Subject: [PATCH 2/2] changed to use deterministic data --- lib/matplotlib/tests/test_datetime.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/lib/matplotlib/tests/test_datetime.py b/lib/matplotlib/tests/test_datetime.py index 44d04801a3c5..08ad2966a91d 100644 --- a/lib/matplotlib/tests/test_datetime.py +++ b/lib/matplotlib/tests/test_datetime.py @@ -150,13 +150,13 @@ def test_bar_label(self): def test_barbs(self): plt.rcParams["date.converter"] = 'concise' - start_date = datetime.datetime.now() + start_date = datetime.datetime(2022, 2, 8, 22) dates = [start_date + datetime.timedelta(hours=i) for i in range(12)] - numbers = np.random.rand(len(dates)) + numbers = np.sin(np.linspace(0, 2 * np.pi, 12)) - u = np.random.rand(len(dates)) - v = np.random.rand(len(dates)) * 100 + u = np.ones(12) * 10 + v = np.arange(0, 120, 10) fig, axes = plt.subplots(nrows=1, ncols=2, figsize=(12, 6)) pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy