Skip to content

Commit 2527f43

Browse files
committed
Drop support for matplotlib < 3.8
1 parent f442813 commit 2527f43

10 files changed

Lines changed: 27 additions & 73 deletions

File tree

‎.circleci/config.yml‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,15 +86,15 @@ workflows:
8686
matrix:
8787
parameters:
8888
jobname:
89-
- "py311-test-image-mpl360-cov"
89+
- "py311-test-image-mpl380-cov"
9090
- "py311-test-image-mpldev-cov"
9191

9292
- deploy-reference-images:
9393
name: baseline-<< matrix.jobname >>
9494
matrix:
9595
parameters:
9696
jobname:
97-
- "py311-test-image-mpl360-cov"
97+
- "py311-test-image-mpl380-cov"
9898
- "py311-test-image-mpldev-cov"
9999
requires:
100100
- << matrix.jobname >>

astropy/tests/figures/py311-test-image-mpl360-cov.json renamed to astropy/tests/figures/py311-test-image-mpl380-cov.json

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[True]": "5364e39cab14f28b08073b31cce3dae8501c0431b1a49985810b764902747c8e",
1010
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[False]": "ee1e46856a19ba472ae9ea4588c614fbbd1b3a4a0787ef40e33f991a8f79d6c0",
1111
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[line]": "516c3882bbaa31a0d241eec2c70aca45b27b44929662371718b10025735db772",
12-
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_contour_overlay": "44fd1a202f8baa894a289bac150b3b0eda9b069a06fc8f49ce14d77e743481e0",
12+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_contour_overlay": "8679305e8a8b5b3f5b896343f4e16dfc65e9289c31505e3b35ef773d7837c8ea",
1313
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_contourf_overlay": "fa928ab57291e8a128009320323ffb8955cd75d28b2a589074defb7b0889b3eb",
1414
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_overlay_features_image": "30d5562cb7a2484db0b898bc886253829de884fbf92bc0e6575f091438ec5f32",
1515
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_curvilinear_grid_patches_image": "ad0a985a324a73b5bea839a231f7537075306c874c279c6a6ea2cfe16529d815",

‎astropy/utils/masked/tests/test_masked.py‎

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1601,11 +1601,6 @@ class TestMaskedQuantityInteractionWithNumpyMA(
16011601

16021602
@pytest.mark.skipif(not HAS_PLT, reason="requires matplotlib.pyplot")
16031603
def test_plt_scatter_masked():
1604-
from astropy.visualization.wcsaxes.utils import MATPLOTLIB_LT_3_8
1605-
1606-
if MATPLOTLIB_LT_3_8:
1607-
pytest.skip("never worked before matplotlib 3.8")
1608-
16091604
# check that plotting Masked data doesn't raise an exception
16101605
# see https://github.com/astropy/astropy/issues/12481
16111606
import matplotlib.pyplot as plt

‎astropy/visualization/wcsaxes/coordinate_helpers.py‎

Lines changed: 3 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
from .grid_paths import get_gridline_path, get_lon_lat_path
2323
from .ticklabels import TickLabels
2424
from .ticks import Ticks
25-
from .utils import MATPLOTLIB_LT_3_8
2625

2726
__all__ = ["CoordinateHelper"]
2827

@@ -859,13 +858,8 @@ def _draw_grid(self, renderer):
859858
p.draw(renderer)
860859

861860
elif self._grid is not None:
862-
if MATPLOTLIB_LT_3_8:
863-
for line in self._grid.collections:
864-
line.set(**self._grid_lines_kwargs)
865-
line.draw(renderer)
866-
else:
867-
self._grid.set(**self._grid_lines_kwargs)
868-
self._grid.draw(renderer)
861+
self._grid.set(**self._grid_lines_kwargs)
862+
self._grid.draw(renderer)
869863

870864
renderer.close_group("grid lines")
871865

@@ -1372,11 +1366,7 @@ def _get_gridline(self, xy_world, pixel, xy_world_round):
13721366

13731367
def _clear_grid_contour(self):
13741368
if hasattr(self, "_grid") and self._grid:
1375-
if MATPLOTLIB_LT_3_8:
1376-
for line in self._grid.collections:
1377-
line.remove()
1378-
else:
1379-
self._grid.remove()
1369+
self._grid.remove()
13801370

13811371
def _update_grid_contour(self):
13821372
if self.coord_index is None:

‎astropy/visualization/wcsaxes/tests/test_misc.py‎

Lines changed: 1 addition & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
22
import warnings
3-
from contextlib import nullcontext
43

54
import matplotlib as mpl
65
import numpy as np
@@ -33,8 +32,6 @@
3332
# https://github.com/matplotlib/matplotlib/issues/23244
3433
TEX_UNAVAILABLE = True
3534

36-
MATPLOTLIB_LT_3_7 = Version(mpl.__version__) < Version("3.7")
37-
3835

3936
def test_grid_regression(ignore_matplotlibrc):
4037
# Regression test for a bug that meant that if the rc parameter
@@ -341,16 +338,7 @@ def test_contour_empty():
341338
fig = Figure()
342339
ax = WCSAxes(fig, [0.1, 0.1, 0.8, 0.8])
343340
fig.add_axes(ax)
344-
345-
if MATPLOTLIB_LT_3_7:
346-
ctx = pytest.warns(
347-
UserWarning, match="No contour levels were found within the data range"
348-
)
349-
else:
350-
ctx = nullcontext()
351-
352-
with ctx:
353-
ax.contour(np.zeros((4, 4)), transform=ax.get_transform("world"))
341+
ax.contour(np.zeros((4, 4)), transform=ax.get_transform("world"))
354342

355343

356344
def test_iterate_coords(ignore_matplotlibrc):

‎astropy/visualization/wcsaxes/utils.py‎

Lines changed: 9 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,8 @@
11
# Licensed under a 3-clause BSD style license - see LICENSE.rst
2-
import matplotlib as mpl
32
import numpy as np
43

54
from astropy import units as u
65
from astropy.coordinates import BaseCoordinateFrame, UnitSphericalRepresentation
7-
from astropy.utils.introspection import minversion
86

97
__all__ = [
108
"select_step_degree",
@@ -13,8 +11,6 @@
1311
"transform_contour_set_inplace",
1412
]
1513

16-
MATPLOTLIB_LT_3_8 = not minversion(mpl, "3.8")
17-
1814

1915
def select_step_degree(dv):
2016
# Modified from axis_artist, supports astropy.units
@@ -138,29 +134,15 @@ def transform_contour_set_inplace(cset, transform):
138134
all_paths = []
139135
pos_level = []
140136
pos_segments = []
141-
142-
if MATPLOTLIB_LT_3_8:
143-
for collection in cset.collections:
144-
paths = collection.get_paths()
145-
if len(paths) == 0:
146-
continue
147-
all_paths.append(paths)
148-
# The last item in pos isn't needed for np.split and in fact causes
149-
# issues if we keep it because it will cause an extra empty array to be
150-
# returned.
151-
pos = np.cumsum([len(x) for x in paths])
152-
pos_segments.append(pos[:-1])
153-
pos_level.append(pos[-1])
154-
else:
155-
paths = cset.get_paths()
156-
if len(paths) > 0:
157-
all_paths.append(paths)
158-
# The last item in pos isn't needed for np.split and in fact causes
159-
# issues if we keep it because it will cause an extra empty array to be
160-
# returned.
161-
pos = np.cumsum([len(x) for x in paths])
162-
pos_segments.append(pos[:-1])
163-
pos_level.append(pos[-1])
137+
paths = cset.get_paths()
138+
if len(paths) > 0:
139+
all_paths.append(paths)
140+
# The last item in pos isn't needed for np.split and in fact causes
141+
# issues if we keep it because it will cause an extra empty array to be
142+
# returned.
143+
pos = np.cumsum([len(x) for x in paths])
144+
pos_segments.append(pos[:-1])
145+
pos_level.append(pos[-1])
164146

165147
# As above the last item isn't needed
166148
pos_level = np.cumsum(pos_level)[:-1]

‎docs/changes/18164.other.rst‎

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
The minimum required Matplotlib version is now 3.8.0.

‎docs/development/testguide.rst‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -680,7 +680,7 @@ hashes and images.
680680

681681
To run the Astropy tests with the image comparison, use e.g.::
682682

683-
tox -e py311-test-image-mpl360-cov
683+
tox -e py311-test-image-mpl380-cov
684684

685685
However, note that the output can be sensitive to the operating system and
686686
specific version of libraries such as freetype. In general, using tox will
@@ -745,7 +745,7 @@ generate it, you should run the tests the first time with::
745745

746746
for example::
747747

748-
tox -e py311-test-image-mpl360-cov -- --mpl-generate-hash-library=astropy/tests/figures/py311-test-image-mpl360-cov.json
748+
tox -e py311-test-image-mpl380-cov -- --mpl-generate-hash-library=astropy/tests/figures/py311-test-image-mpl380-cov.json
749749

750750
Then add and commit the new JSON file and try running the tests again. The tests
751751
may fail in the continuous integration if e.g. the freetype version does not

‎pyproject.toml‎

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -53,7 +53,7 @@ dependencies = [
5353
# Recommended run-time dependencies to enable a lot of functionality within Astropy.
5454
recommended = [
5555
"scipy>=1.9.2",
56-
"matplotlib>=3.6.0",
56+
"matplotlib>=3.8.0",
5757
]
5858
# Optional IPython-related behavior is in many places in Astropy. IPython is a complex
5959
# dependency that occasionally requires pinning one of it's upstream dependencies. If
@@ -599,9 +599,9 @@ ignore = [
599599
type_incorrect_long = "The changelog file you added is not one of the allowed types. Please use one of the types described in the changelog [README](https://github.com/astropy/astropy/blob/main/docs/changes/README.rst)"
600600
number_incorrect_long = "The number in the changelog file you added does not match the number of this pull request. Please rename the file."
601601

602-
[tool.gilesbot.circleci_artifacts.py311-test-image-mpl360]
603-
url = ".tmp/py311-test-image-mpl360/results/fig_comparison.html"
604-
message = "Click details to see the figure test comparisons, for py311-test-image-mpl360."
602+
[tool.gilesbot.circleci_artifacts.py311-test-image-mpl380]
603+
url = ".tmp/py311-test-image-mpl380/results/fig_comparison.html"
604+
message = "Click details to see the figure test comparisons, for py311-test-image-mpl380."
605605
report_on_fail = true
606606

607607
[tool.gilesbot.circleci_artifacts.py311-test-image-mpldev]

‎tox.ini‎

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tox]
22
envlist =
3-
py{311,312,313,dev}-test{,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy123,-numpy124,-numpy125,-mpl360}{,-cov}{,-clocale}{,-fitsio}{,-noscipy}
3+
py{311,312,313,dev}-test{,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy123,-numpy124,-numpy125,-mpl380}{,-cov}{,-clocale}{,-fitsio}{,-noscipy}
44
# Only these two exact tox environments have corresponding figure hash files.
5-
py311-test-image-mpl360-cov
5+
py311-test-image-mpl380-cov
66
py311-test-image-mpldev-cov
77
build_docs
88
linkcheck
@@ -54,7 +54,7 @@ description =
5454
numpy124: with numpy 1.24.*
5555
numpy125: with numpy 1.25.*
5656
image: with image tests
57-
mpl360: with matplotlib 3.6.0
57+
mpl380: with matplotlib 3.8.0
5858
mpldev: with the latest developer version of matplotlib
5959
double: twice in a row to check for global state changes
6060
noscipy: without scipy-dev
@@ -64,9 +64,7 @@ deps =
6464
numpy124: numpy==1.24.*
6565
numpy125: numpy==1.25.*
6666

67-
mpl360: matplotlib==3.6.0
68-
# mpl 3.6.0 isn't compatible with numpy 2.0 but didn't include a pin
69-
mpl360: numpy<2.0
67+
mpl380: matplotlib==3.8.0
7068

7169
image: latex
7270
image, devinfra: scipy

0 commit comments

Comments
 (0)