Fix compatibility with Matplotlib 3.6

This commit is contained in:
Elliott Sales de Andrade 2022-08-20 18:14:49 -04:00
commit c1c216adbe
6 changed files with 164 additions and 3 deletions

View file

@ -1,7 +1,7 @@
From 722b2ba6dc28d73aeb2ca8cc7d42178ae0410899 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 26 Feb 2018 02:42:50 -0500
Subject: [PATCH 1/4] Increase tolerance for new FreeType.
Subject: [PATCH 1/5] Increase tolerance for new FreeType.
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---

View file

@ -1,7 +1,7 @@
From e589a1a90a13b0f0726885c78307d72c7bc507b5 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Sat, 21 May 2022 01:36:44 -0400
Subject: [PATCH 2/4] Use pkg-config to find GEOS instead of geos-config
Subject: [PATCH 2/5] Use pkg-config to find GEOS instead of geos-config
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---

View file

@ -1,7 +1,7 @@
From 05e742c7be204919bd71a5cb68388f51ea8e1055 Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Mon, 23 May 2022 02:42:38 -0400
Subject: [PATCH 3/4] Remove extraneous insertion of default compiler paths
Subject: [PATCH 3/5] Remove extraneous insertion of default compiler paths
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---

View file

@ -0,0 +1,51 @@
From ea2967ba557f4f5a4fee19cd71c4e5d1f1786532 Mon Sep 17 00:00:00 2001
From: HOLZSCHUCH Nicolas <nicolas.holzschuch@inria.fr>
Date: Sun, 26 Jun 2022 14:57:00 +0200
Subject: [PATCH 4/5] Replace _autoscaleX_on with get_autoscalex_on()
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
lib/cartopy/mpl/geoaxes.py | 11 ++++++-----
1 file changed, 6 insertions(+), 5 deletions(-)
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
index fcedf2f3..92b5aa16 100644
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -488,15 +488,16 @@ class GeoAxes(matplotlib.axes.Axes):
data_lim = self.dataLim.frozen().get_points()
view_lim = self.viewLim.frozen().get_points()
other = (self.ignore_existing_data_limits,
- self._autoscaleXon, self._autoscaleYon)
+ self.get_autoscalex_on(), self.get_autoscaley_on())
try:
yield
finally:
if hold:
self.dataLim.set_points(data_lim)
self.viewLim.set_points(view_lim)
- (self.ignore_existing_data_limits,
- self._autoscaleXon, self._autoscaleYon) = other
+ self.ignore_existing_data_limits = other[0]
+ self.set_autoscalex_on(other[1])
+ self.set_autoscaley_on(other[2])
def _draw_preprocess(self, renderer):
"""
@@ -943,11 +944,11 @@ class GeoAxes(matplotlib.axes.Axes):
matplotlib.axes.Axes.autoscale_view(self, tight=tight,
scalex=scalex, scaley=scaley)
# Limit the resulting bounds to valid area.
- if scalex and self._autoscaleXon:
+ if scalex and self.get_autoscalex_on():
bounds = self.get_xbound()
self.set_xbound(max(bounds[0], self.projection.x_limits[0]),
min(bounds[1], self.projection.x_limits[1]))
- if scaley and self._autoscaleYon:
+ if scaley and self.get_autoscaley_on():
bounds = self.get_ybound()
self.set_ybound(max(bounds[0], self.projection.y_limits[0]),
min(bounds[1], self.projection.y_limits[1]))
--
2.36.1

View file

@ -0,0 +1,105 @@
From d6e8b5c1308571f3dabef82d3402f78a15e0ecce Mon Sep 17 00:00:00 2001
From: Elliott Sales de Andrade <quantum.analyst@gmail.com>
Date: Sat, 20 Aug 2022 22:28:48 -0400
Subject: [PATCH 5/5] Fix Axes clearing with Matplotlib 3.6+
Fix new deprecation warnings from Matplotlib 3.6 in tests
Signed-off-by: Elliott Sales de Andrade <quantum.analyst@gmail.com>
---
lib/cartopy/mpl/geoaxes.py | 18 ++++++++++++++----
lib/cartopy/tests/mpl/test_images.py | 3 +--
lib/cartopy/tests/mpl/test_pseudo_color.py | 6 +++---
3 files changed, 18 insertions(+), 9 deletions(-)
diff --git a/lib/cartopy/mpl/geoaxes.py b/lib/cartopy/mpl/geoaxes.py
index 92b5aa16..c568a124 100644
--- a/lib/cartopy/mpl/geoaxes.py
+++ b/lib/cartopy/mpl/geoaxes.py
@@ -596,9 +596,8 @@ class GeoAxes(matplotlib.axes.Axes):
def __str__(self):
return '< GeoAxes: %s >' % self.projection
- def cla(self):
- """Clear the current axes and adds boundary lines."""
- result = matplotlib.axes.Axes.cla(self)
+ def _clear(self):
+ """Clear the current axes and add boundary lines."""
self.xaxis.set_visible(False)
self.yaxis.set_visible(False)
# Enable tight autoscaling.
@@ -614,7 +613,18 @@ class GeoAxes(matplotlib.axes.Axes):
self.dataLim.intervalx = self.projection.x_limits
self.dataLim.intervaly = self.projection.y_limits
- return result
+ if mpl.__version__ >= '3.6':
+ def clear(self):
+ """Clear the current Axes and add boundary lines."""
+ result = matplotlib.axes.Axes.clear(self)
+ self._clear()
+ return result
+ else:
+ def cla(self):
+ """Clear the current Axes and add boundary lines."""
+ result = matplotlib.axes.Axes.cla(self)
+ self._clear()
+ return result
def format_coord(self, x, y):
"""
diff --git a/lib/cartopy/tests/mpl/test_images.py b/lib/cartopy/tests/mpl/test_images.py
index 8fc41a14..002b45b2 100644
--- a/lib/cartopy/tests/mpl/test_images.py
+++ b/lib/cartopy/tests/mpl/test_images.py
@@ -9,7 +9,6 @@ import types
import numpy as np
import matplotlib.pyplot as plt
-import matplotlib.cm as cm
import matplotlib.colors as colors
from PIL import Image
import pytest
@@ -136,7 +135,7 @@ def test_imshow_rgba():
# tests that the alpha of a RGBA array passed to imshow is set to 0
# instead of masked
z = np.ones((100, 100))*0.5
- cmap = cm.get_cmap()
+ cmap = plt.get_cmap()
norm = colors.Normalize(vmin=0, vmax=1)
z1 = cmap(norm(z))
plt_crs = ccrs.LambertAzimuthalEqualArea()
diff --git a/lib/cartopy/tests/mpl/test_pseudo_color.py b/lib/cartopy/tests/mpl/test_pseudo_color.py
index 8e97d128..ec0655b2 100644
--- a/lib/cartopy/tests/mpl/test_pseudo_color.py
+++ b/lib/cartopy/tests/mpl/test_pseudo_color.py
@@ -95,7 +95,7 @@ def test_pcolormesh_datalim():
# Z with the same shape as X/Y to force the interpolation
z = np.zeros(xs.shape)
- ax = plt.subplot(2, 1, 1, projection=ccrs.PlateCarree())
+ ax = plt.subplot(3, 1, 1, projection=ccrs.PlateCarree())
coll = ax.pcolormesh(xs, ys, z, shading='auto',
transform=ccrs.PlateCarree())
@@ -107,7 +107,7 @@ def test_pcolormesh_datalim():
y = [-10, 10]
xs, ys = np.meshgrid(x, y)
- ax = plt.subplot(2, 1, 1, projection=ccrs.PlateCarree())
+ ax = plt.subplot(3, 1, 2, projection=ccrs.PlateCarree())
coll = ax.pcolormesh(xs, ys, z, shading='auto',
transform=ccrs.PlateCarree())
@@ -119,7 +119,7 @@ def test_pcolormesh_datalim():
y = [-10, 10]
xs, ys = np.meshgrid(x, y)
- ax = plt.subplot(2, 1, 1, projection=ccrs.Orthographic())
+ ax = plt.subplot(3, 1, 3, projection=ccrs.Orthographic())
coll = ax.pcolormesh(xs, ys, z, shading='auto',
transform=ccrs.PlateCarree())
--
2.36.1

View file

@ -20,6 +20,11 @@ Patch0001: 0001-Increase-tolerance-for-new-FreeType.patch
# https://bugzilla.redhat.com/show_bug.cgi?id=2088864
Patch0002: 0002-Use-pkg-config-to-find-GEOS-instead-of-geos-config.patch
Patch0003: 0003-Remove-extraneous-insertion-of-default-compiler-path.patch
# Fix compatibility with Matplotlib 3.6
# https://github.com/SciTools/cartopy/pull/2054
Patch0004: 0004-Replace-_autoscaleX_on-with-get_autoscalex_on.patch
# https://github.com/SciTools/cartopy/pull/2071
Patch0005: 0005-Fix-Axes-clearing-with-Matplotlib-3.6.patch
BuildRequires: git-core
BuildRequires: gcc-c++