From f4221f0a34b6999cd6ab8e30554b36dee1f8c1a2 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 23 Jun 2024 20:26:57 -0700 Subject: [PATCH 1/3] Add test for #9155 I can't get this to fail locally, so adding a test to assess what's going on. Alos excludes matplotlib from type exclusions --- pyproject.toml | 1 - xarray/tests/test_plot.py | 8 ++++++++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index db64d7a18c5..e836c7c3e53 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -115,7 +115,6 @@ module = [ "h5netcdf.*", "h5py.*", "iris.*", - "matplotlib.*", "mpl_toolkits.*", "nc_time_axis.*", "numbagg.*", diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index a44b621a981..4c46f10c11d 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -3406,3 +3406,11 @@ def test_plot1d_filtered_nulls() -> None: actual = pc.get_offsets().shape[0] assert expected == actual + +@requires_matplotlib +def test_9155() -> None: + # A test for types from issue #9155 + + data = xr.DataArray([1, 2, 3], dims=["x"]) + fig, ax = plt.subplots(ncols=1, nrows=1) + data.plot(ax=ax) From 01138a5987dc6aaf57b9077f5622db45273f883f Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 24 Jun 2024 03:27:36 +0000 Subject: [PATCH 2/3] [pre-commit.ci] auto fixes from pre-commit.com hooks for more information, see https://pre-commit.ci --- xarray/tests/test_plot.py | 1 + 1 file changed, 1 insertion(+) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 4c46f10c11d..497758ac9ed 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -3407,6 +3407,7 @@ def test_plot1d_filtered_nulls() -> None: assert expected == actual + @requires_matplotlib def test_9155() -> None: # A test for types from issue #9155 From eeb02c1da8b06d756b31b3d34a9451687482c7d8 Mon Sep 17 00:00:00 2001 From: Maximilian Roos Date: Sun, 23 Jun 2024 20:39:33 -0700 Subject: [PATCH 3/3] --- xarray/tests/test_plot.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py index 497758ac9ed..b302ad3af93 100644 --- a/xarray/tests/test_plot.py +++ b/xarray/tests/test_plot.py @@ -3412,6 +3412,7 @@ def test_plot1d_filtered_nulls() -> None: def test_9155() -> None: # A test for types from issue #9155 - data = xr.DataArray([1, 2, 3], dims=["x"]) - fig, ax = plt.subplots(ncols=1, nrows=1) - data.plot(ax=ax) + with figure_context(): + data = xr.DataArray([1, 2, 3], dims=["x"]) + fig, ax = plt.subplots(ncols=1, nrows=1) + data.plot(ax=ax)