Skip to content

Commit

Permalink
Update contourf call check for mpl 3.8
Browse files Browse the repository at this point in the history
  • Loading branch information
ksunden committed Sep 15, 2023
1 parent c537238 commit c7391fc
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion xarray/tests/test_plot.py
Original file line number Diff line number Diff line change
Expand Up @@ -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


Expand Down

0 comments on commit c7391fc

Please sign in to comment.