Fix tests with Matplotlib 3.8.0

This commit is contained in:
Elliott Sales de Andrade
2023-09-15 02:03:11 -04:00
parent dd372c6ddb
commit ad60aec436
2 changed files with 31 additions and 0 deletions
+29
View File
@@ -0,0 +1,29 @@
From c7391fca66e1fd24b175cfffab692af20628fe2b Mon Sep 17 00:00:00 2001
From: Kyle Sunden <git@ksunden.space>
Date: Thu, 14 Sep 2023 20:18:04 -0500
Subject: [PATCH] Update contourf call check for mpl 3.8
---
xarray/tests/test_plot.py | 9 ++++++++-
1 file changed, 8 insertions(+), 1 deletion(-)
diff --git a/xarray/tests/test_plot.py b/xarray/tests/test_plot.py
index 8b2dfbdec4..a6c15a8600 100644
--- a/xarray/tests/test_plot.py
+++ b/xarray/tests/test_plot.py
@@ -167,7 +167,14 @@ def imshow_called(self, plotmethod):
def contourf_called(self, plotmethod):
plotmethod()
- paths = plt.gca().findobj(mpl.collections.PathCollection)
+
+ # Compatible with mpl before (PathCollection) and after (QuadContourSet) 3.8
+ def matchfunc(x):
+ return isinstance(
+ x, (mpl.collections.PathCollection, mpl.contour.QuadContourSet)
+ )
+
+ paths = plt.gca().findobj(matchfunc)
return len(paths) > 0
+2
View File
@@ -16,6 +16,8 @@ Source1: https://github.com/pydata/xarray-data/archive/%{data_commit}/xar
# All Fedora specific.
Patch0001: 0001-DOC-Skip-examples-using-unpackaged-dependencies.patch
Patch0002: 0002-DOC-Don-t-print-out-conda-pip-environment.patch
# Fix tests with Matplotlib 3.8.0.
Patch0003: https://github.com/pydata/xarray/pull/8186.patch
BuildArch: noarch