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