Skip to content

Commit

Permalink
Merge pull request #2258 from rcomer/mpl3.5-min-pin
Browse files Browse the repository at this point in the history
Bump minimum Matplotlib version to 3.5
  • Loading branch information
dopplershift authored Oct 5, 2023
2 parents e424784 + 178684c commit 515991d
Show file tree
Hide file tree
Showing 6 changed files with 15 additions and 14 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/ci-testing.yml
Original file line number Diff line number Diff line change
Expand Up @@ -33,7 +33,7 @@ jobs:
if: matrix.python-version == '3.9' && matrix.os == 'ubuntu-latest'
id: minimum-packages
run: |
pip install cython==0.29.24 matplotlib==3.4.3 numpy==1.21 owslib==0.24.1 pyproj==3.1 scipy==1.6.3 shapely==1.7.1
pip install cython==0.29.24 matplotlib==3.5.3 numpy==1.21 owslib==0.24.1 pyproj==3.1 scipy==1.6.3 shapely==1.7.1
- name: Coverage packages
id: coverage
Expand Down
2 changes: 1 addition & 1 deletion INSTALL
Original file line number Diff line number Diff line change
Expand Up @@ -62,7 +62,7 @@ Further information about the required dependencies can be found here:
**Python** 3.9 or later (https://www.python.org/)
Python 2 support was removed in v0.19.

**Matplotlib** 3.4 or later (https://matplotlib.org/)
**Matplotlib** 3.5 or later (https://matplotlib.org/)
Python package for 2D plotting. Python package required for any
graphical capabilities.

Expand Down
4 changes: 2 additions & 2 deletions lib/cartopy/mpl/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@


_MPL_VERSION = packaging.version.parse(matplotlib.__version__)
_MPL_34 = _MPL_VERSION.release[:2] >= (3, 4)
_MPL_35 = _MPL_VERSION.release[:2] >= (3, 5)
_MPL_36 = _MPL_VERSION.release[:2] >= (3, 6)
_MPL_38 = _MPL_VERSION.release[:2] >= (3, 8)

assert _MPL_34, 'Cartopy is only supported with Matplotlib 3.4 or greater.'
assert _MPL_35, 'Cartopy is only supported with Matplotlib 3.5 or greater.'
6 changes: 3 additions & 3 deletions lib/cartopy/tests/mpl/test_crs.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,12 +8,12 @@
import pytest

import cartopy.crs as ccrs
from cartopy.mpl import _MPL_35
from cartopy.mpl import _MPL_36


@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(
filename="igh_land.png", tolerance=0.5 if _MPL_35 else 3.6)
filename="igh_land.png", tolerance=0.5 if _MPL_36 else 3.6)
def test_igh_land():
crs = ccrs.InterruptedGoodeHomolosine(emphasis="land")
ax = plt.axes(projection=crs)
Expand All @@ -24,7 +24,7 @@ def test_igh_land():

@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(filename="igh_ocean.png",
tolerance=0.5 if _MPL_35 else 4.5)
tolerance=0.5 if _MPL_36 else 4.5)
def test_igh_ocean():
crs = ccrs.InterruptedGoodeHomolosine(
central_longitude=-160, emphasis="ocean"
Expand Down
6 changes: 5 additions & 1 deletion lib/cartopy/tests/mpl/test_gridliner.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
from shapely.geos import geos_version

import cartopy.crs as ccrs
from cartopy.mpl import _MPL_36
from cartopy.mpl.geoaxes import GeoAxes
from cartopy.mpl.gridliner import (LATITUDE_FORMATTER, LONGITUDE_FORMATTER,
Gridliner, classic_formatter,
Expand Down Expand Up @@ -497,7 +498,10 @@ def test_gridliner_title_adjust():
plt.rcParams['axes.titley'] = None

fig = plt.figure(layout='constrained')
fig.get_layout_engine().set(h_pad=1/8)
if _MPL_36:
fig.get_layout_engine().set(h_pad=1/8)
else:
fig.set_constrained_layout_pads(h_pad=1/8)
for n, proj in enumerate(projs, 1):
ax = fig.add_subplot(2, 2, n, projection=proj)
ax.coastlines()
Expand Down
9 changes: 3 additions & 6 deletions lib/cartopy/tests/mpl/test_mpl_integration.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
import pytest

import cartopy.crs as ccrs
from cartopy.mpl import _MPL_35, _MPL_38
from cartopy.mpl import _MPL_38


@pytest.mark.natural_earth
Expand Down Expand Up @@ -196,8 +196,7 @@ def test_simple_global():
id='ObliqueMercator_rotated',
),
])
@pytest.mark.mpl_image_compare(
tolerance=0.5 if _MPL_35 else 0.97, style='mpl20')
@pytest.mark.mpl_image_compare(style='mpl20')
def test_global_map(proj):
if isinstance(proj, tuple):
proj, kwargs = proj
Expand Down Expand Up @@ -957,9 +956,7 @@ def test_barbs_1d_transformed():


@pytest.mark.natural_earth
@pytest.mark.mpl_image_compare(
filename='streamplot.png', style='mpl20',
tolerance=0.5 if _MPL_35 else 9.77)
@pytest.mark.mpl_image_compare(filename='streamplot.png', style='mpl20')
def test_streamplot():
x = np.arange(-60, 42.5, 2.5)
y = np.arange(30, 72.5, 2.5)
Expand Down

0 comments on commit 515991d

Please sign in to comment.