Skip to content

Commit b58ca80

Browse files
committed
MNT: Bump matplotlib minversion to 3.2
and remove unnecessary code added in astropy#8818 and astropy#8782 Add new JSON for figure tests.
1 parent ce60744 commit b58ca80

10 files changed

Lines changed: 72 additions & 51 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-
- "py39-test-image-mpl311-cov"
89+
- "py39-test-image-mpl322-cov"
9090
- "py39-test-image-mpldev-cov"
9191

9292
- deploy-reference-images:
9393
name: baseline-<< matrix.jobname >>
9494
matrix:
9595
parameters:
9696
jobname:
97-
- "py39-test-image-mpl311-cov"
97+
- "py39-test-image-mpl322-cov"
9898
- "py39-test-image-mpldev-cov"
9999
requires:
100100
- << matrix.jobname >>
Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
{
2+
"astropy.visualization.wcsaxes.tests.test_frame.TestFrame.test_custom_frame": "4cb4b20fcfcdd8006d8defd8ad192ee56f765f38f00c8858f4823892d1fbad3f",
3+
"astropy.visualization.wcsaxes.tests.test_frame.TestFrame.test_update_clip_path_rectangular": "c871dcd499fae8f50f64127e5c34b4ccdd82a3429f299b3ac1a2e071f80f1055",
4+
"astropy.visualization.wcsaxes.tests.test_frame.TestFrame.test_update_clip_path_nonrectangular": "75d4009076c613e133fa528112e184815ad53be695532eea3bed8b0a788f6e13",
5+
"astropy.visualization.wcsaxes.tests.test_frame.TestFrame.test_update_clip_path_change_wcs": "508c861f66ab9071c6e84fcdf0e9e7f89f56638b3c25598acec976c7bc32ddb5",
6+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_tight_layout": "509512285df82665aa804c93a924a90c034531c3ee53ac222df804f8cea759b1",
7+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_image_plot": "d0571df4d52b06c241f427e7db05889b79856f002a4cd66657c7606a50fb1761",
8+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axes_off": "7e8ef6db9d193397fe8cec85f2d57ca8a4100c2131cfe7e6f94eeb75c67422fe",
9+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[True]": "428cb0032c53919a59d21091212cb6a2690e85af3db8e4baf861cf1c646b9f02",
10+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[False]": "27a988c95f3d90ca5cd7a367275a2df2a69e098bf2c5e2fda2f0a786c4ceb1e4",
11+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axisbelow[line]": "6842ac39dd39cf9dd4f06b04eab86a544aac22619231365abcfdfb272822d9a8",
12+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_contour_overlay": "966b070f76b907eceb8e1e1eccb8f07d538df9089e9317553d0fc9908847f513",
13+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_contourf_overlay": "27c11bcb522c9590f32983f54a97cca950e95b6a6bd2c07561e41c44f0bbf107",
14+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_overlay_features_image": "32e6a7cfd47d11a5586a1c797c6f1ebfc893d6e81da7826bbbb4e7ba5d7da9b6",
15+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_curvilinear_grid_patches_image": "ecc65a1ae5b2c26e8a98393d6eec519833815a780c2bce769d1ba70d95825aeb",
16+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_cube_slice_image": "4ce20473d7510f8925536e6a053f76d8565a701ba23fe72792cb2a63356125ae",
17+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_cube_slice_image_lonlat": "61a327f2d4142fe4f104519810e246e51c8fc0c9b3b6476519c872069c35dfd9",
18+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_plot_coord": "2d114d7769e939b086111f5e03b73a492bbe13f529191e612accb148160085b1",
19+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_scatter_coord": "2d114d7769e939b086111f5e03b73a492bbe13f529191e612accb148160085b1",
20+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_plot_line": "8529fd25ae012dfc5b50a104d63c9690e14924bbc4ac50f5ff7d64a624edb2f4",
21+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_changed_axis_units": "f790329265f9514333972500b9378bd1ef8e23946e7ed2372e41c70e94b2ccac",
22+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_minor_ticks": "9542664add71fb36481cafd1a7d04f198d0991f2f4ab511e778481b7132ec046",
23+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_ticks_labels": "d1757b139dfda35c355e6b8bb403fbb6ea0194df484968df1818f1b76fb2c73e",
24+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_rcparams": "2c3b7f96cf950a3d233a9f551432ee01f25fbc7173a579a8dbbce02dc297808f",
25+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_tick_angles": "49ac60171ec7d3c7e4458d429529326b1fd12963d7199725cfdda1ad39c213b3",
26+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_tick_angles_non_square_axes": "0b1c86bb02ccaf595e7a6b98f4dfa8046a1b95d6fd7e07508b5bb0164a287eba",
27+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_set_coord_type": "cda50c843c9985615066447ba4c3bb8fa3688d1d0634cdf3d18d0eb97fa6ad4c",
28+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_ticks_regression": "493be1fc89b8aabb17b1fd5c2ed2d445b42fb9ab99b454979158a103c74dca28",
29+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_axislabels_regression": "3b63bcf105f21ef2edd463c788dfe230d55b1b5a7af89f386ca393d993806bdd",
30+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_noncelestial_angular": "55528dfa5abd39410b686f39b4b9480602ea55af69e4130d54f3519909c054b3",
31+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_patches_distortion": "af520057280e1451550d8112a8c608963205577c4a2986b25666416bed4b9fd0",
32+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_quadrangle": "ddabd55782b7a5a7e0750a0090bfed65361bd538568d7d2f415d7dc7da9228ef",
33+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_beam_shape_from_args": "1f0309cd10d3484741638d325ac68d09e73916a47fdbc7da46a8094039232395",
34+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_beam_shape_from_header": "129f4f2403909feff8dd3ade101c73fe47b584c0e4d8787dcefdc35884726f18",
35+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_scalebar": "e483643ce8324032b35a2e5ba4508144d0770ace2388badef2df0d521c43e8a5",
36+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_elliptical_frame": "d0be63372ad45e8f53a21eb788bcab16c454b69ceb182ee513013a659045363a",
37+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_hms_labels": "5d81e19b2b3304f977f0b198113c699696f5f793434405a7b4ec5d6773c636a8",
38+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_latex_labels": "ac7be4f16d29037eb6d0fdc8de49450777527140822528e8bfbfd5f0fb72a50d",
39+
"astropy.visualization.wcsaxes.tests.test_images.TestBasic.test_tick_params": "da1598848d8261551a1f25ae8a5da669120d9a0618b5ad5ed8bf71714ef0d37f",
40+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_1d_wcs": "c8175a90f7b15c62a6b06282b62bb23dbc7867dd04ee8f16f19c19b37c341b78",
41+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_1d_wcs_format_unit": "eae2365ccf59100341d692621778a3c121d3aebdae8c63d3770375b7a308e0b3",
42+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_2d_wcs_correlated": "16cf5a65f9a49b1307415183f2e1f3750f05427cd942b1329e35e1dac1d54836",
43+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_1d_sliced_low_level_wcs[slices0-custom:pos.helioprojective.lon]": "b7cdbcddc0757c2add2c5cab2772c9772280ea114696ec39da75b6a62b7f631f",
44+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_1d_sliced_low_level_wcs[slices1-custom:pos.helioprojective.lat]": "9828decfc27dbc7ec9e35ca674eac2db2a4d1bc3348b29845842b30cae48b657",
45+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_put_varying_axis_on_bottom_lon[slices0-hpln]": "b7cdbcddc0757c2add2c5cab2772c9772280ea114696ec39da75b6a62b7f631f",
46+
"astropy.visualization.wcsaxes.tests.test_images.test_1d_plot_put_varying_axis_on_bottom_lon[slices1-hplt]": "9828decfc27dbc7ec9e35ca674eac2db2a4d1bc3348b29845842b30cae48b657",
47+
"astropy.visualization.wcsaxes.tests.test_images.test_allsky_labels_wrap": "56f9fb3bcfbba326347ad91c94ae7beb4a615c042ab6c42c38b7ce8d528135bf",
48+
"astropy.visualization.wcsaxes.tests.test_images.test_tickable_gridlines": "9eb6bbc56905917e9f264dc240edb6f29d66467ffb7ee0434420a52a9231030f",
49+
"astropy.visualization.wcsaxes.tests.test_transform_coord_meta.TestTransformCoordMeta.test_coords_overlay": "382af290d2231d93a6a529e581e07a76912be48ad974abe4a7021eda15f37ba2",
50+
"astropy.visualization.wcsaxes.tests.test_transform_coord_meta.TestTransformCoordMeta.test_coords_overlay_auto_coord_meta": "069adb197b6c078e5354c10dec96808cd8a61ab50e079ee8806a388a6a5be3a0",
51+
"astropy.visualization.wcsaxes.tests.test_transform_coord_meta.TestTransformCoordMeta.test_direct_init": "f1916439fdc8be04568545db6169687f3ea8af4692ad7a9bede5a39eb5562896",
52+
"astropy.visualization.wcsaxes.tests.test_wcsapi.test_wcsapi_5d_with_names": "1db4eb1d01da87647c19dde5bd115555f65d3b2d1036a82c41020b938c22bb7f"
53+
}

astropy/visualization/tests/test_norm.py

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,18 +4,12 @@
44
import pytest
55
from numpy import ma
66
from numpy.testing import assert_allclose, assert_equal
7-
from packaging.version import Version
87

98
from astropy.utils.compat.optional_deps import HAS_MATPLOTLIB, HAS_PLT
109
from astropy.visualization.interval import ManualInterval, PercentileInterval
1110
from astropy.visualization.mpl_normalize import ImageNormalize, imshow_norm, simple_norm
1211
from astropy.visualization.stretch import LogStretch, PowerStretch, SqrtStretch
1312

14-
if HAS_MATPLOTLIB:
15-
import matplotlib
16-
17-
MATPLOTLIB_LT_32 = Version(matplotlib.__version__) < Version("3.2")
18-
1913
DATA = np.linspace(0.0, 15.0, 6)
2014
DATA2 = np.arange(3)
2115
DATA2SCL = 0.5 * DATA2

astropy/visualization/tests/test_units.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,7 @@ def test_incompatible_units():
7979
def test_quantity_subclass():
8080
"""Check that subclasses are recognized.
8181
82-
This sadly is not done by matplotlib.units itself, though
83-
there is a PR to change it:
84-
https://github.com/matplotlib/matplotlib/pull/13536
82+
Also see https://github.com/matplotlib/matplotlib/pull/13536
8583
"""
8684
plt.figure()
8785

astropy/visualization/time.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,13 +154,6 @@ def __init__(self, converter, *args, **kwargs):
154154
self.set_useOffset(False)
155155
self.set_scientific(False)
156156

157-
def __call__(self, value, pos=None):
158-
# Needed for Matplotlib <3.1
159-
if self._converter.format in STR_FORMATS:
160-
return self.format_ticks([value])[0]
161-
else:
162-
return super().__call__(value, pos=pos)
163-
164157
def format_ticks(self, values):
165158
if len(values) == 0:
166159
return []

astropy/visualization/units.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -34,18 +34,6 @@ def quantity_support(format="latex_inline"):
3434

3535
from astropy import units as u
3636

37-
# import Angle just so we have a more or less complete list of Quantity
38-
# subclasses loaded - matplotlib needs them all separately!
39-
# NOTE: in matplotlib >=3.2, subclasses will be recognized automatically,
40-
# and once that becomes our minimum version, we can remove this,
41-
# adding just u.Quantity itself to the registry.
42-
from astropy.coordinates import Angle # noqa: F401
43-
44-
# Get all subclass for Quantity, since matplotlib checks on class,
45-
# not subclass.
46-
def all_issubclass(cls):
47-
return {cls}.union([s for c in cls.__subclasses__() for s in all_issubclass(c)])
48-
4937
def rad_fn(x, pos=None):
5038
n = int((x / np.pi) * 2.0 + 0.25)
5139
if n == 0:
@@ -60,16 +48,11 @@ def rad_fn(x, pos=None):
6048
return f"{n}π/2"
6149

6250
class MplQuantityConverter(units.ConversionInterface):
63-
_all_issubclass_quantity = all_issubclass(u.Quantity)
64-
6551
def __init__(self):
6652
# Keep track of original converter in case the context manager is
6753
# used in a nested way.
68-
self._original_converter = {}
69-
70-
for cls in self._all_issubclass_quantity:
71-
self._original_converter[cls] = units.registry.get(cls)
72-
units.registry[cls] = self
54+
self._original_converter = {u.Quantity: units.registry.get(u.Quantity)}
55+
units.registry[u.Quantity] = self
7356

7457
@staticmethod
7558
def axisinfo(unit, axis):
@@ -108,10 +91,9 @@ def __enter__(self):
10891
return self
10992

11093
def __exit__(self, type, value, tb):
111-
for cls in self._all_issubclass_quantity:
112-
if self._original_converter[cls] is None:
113-
del units.registry[cls]
114-
else:
115-
units.registry[cls] = self._original_converter[cls]
94+
if self._original_converter[u.Quantity] is None:
95+
del units.registry[u.Quantity]
96+
else:
97+
units.registry[u.Quantity] = self._original_converter[u.Quantity]
11698

11799
return MplQuantityConverter()

docs/changes/14321.other.rst

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
Dropped support for matplotlib 3.1. Minimum version is now 3.2.

docs/development/testguide.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -763,7 +763,7 @@ hashes and images.
763763

764764
To run the Astropy tests with the image comparison, use e.g.::
765765

766-
tox -e py39-test-image-mpl311-cov
766+
tox -e py39-test-image-mpl322-cov
767767

768768
However, note that the output can be sensitive to the operating system and
769769
specific version of libraries such as freetype. In general, using tox will

setup.cfg

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,10 @@ test_all = # Required for testing, plus packages used by particular tests.
7272
sgp4>=2.3
7373
recommended =
7474
scipy>=1.5
75-
matplotlib>=3.1,!=3.4.0,!=3.5.2
75+
matplotlib>=3.2,!=3.4.0,!=3.5.2
7676
all =
7777
scipy>=1.5
78-
matplotlib>=3.1,!=3.4.0,!=3.5.2
78+
matplotlib>=3.2,!=3.4.0,!=3.5.2
7979
certifi
8080
dask[array]
8181
h5py
@@ -100,7 +100,7 @@ docs =
100100
sphinx-astropy>=1.6
101101
pytest>=7.0
102102
scipy>=1.3
103-
matplotlib>=3.1,!=3.4.0,!=3.5.2
103+
matplotlib>=3.2,!=3.4.0,!=3.5.2
104104
towncrier<22.12.0
105105
sphinx-changelog>=1.2.0
106106
Jinja2>=3.0

tox.ini

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,8 +1,8 @@
11
[tox]
22
envlist =
3-
py{38,39,310,311,dev}-test{,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy120,-numpy121,-numpy122,-numpy123,-mpl311}{,-cov}{,-clocale}{,-fitsio}
3+
py{38,39,310,311,dev}-test{,-recdeps,-alldeps,-oldestdeps,-devdeps,-devinfra,-predeps,-numpy120,-numpy121,-numpy122,-numpy123,-mpl322}{,-cov}{,-clocale}{,-fitsio}
44
# Only these two exact tox environments have corresponding figure hash files.
5-
py39-test-image-mpl311-cov
5+
py39-test-image-mpl322-cov
66
py39-test-image-mpldev-cov
77
build_docs
88
linkcheck
@@ -52,7 +52,7 @@ description =
5252
numpy122: with numpy 1.22.*
5353
numpy123: with numpy 1.23.*
5454
image: with image tests
55-
mpl311: with matplotlib 3.1.1
55+
mpl322: with matplotlib 3.2.2
5656
mpldev: with the latest developer version of matplotlib
5757
double: twice in a row to check for global state changes
5858

@@ -62,7 +62,7 @@ deps =
6262
numpy122: numpy==1.22.*
6363
numpy123: numpy==1.23.*
6464

65-
mpl311: matplotlib==3.1.1
65+
mpl322: matplotlib==3.2.2
6666

6767
image: latex
6868
image: scipy
@@ -74,7 +74,7 @@ deps =
7474
# The oldestdeps factor is intended to be used to install the oldest versions of all
7575
# dependencies that have a minimum version.
7676
oldestdeps: numpy==1.20.*
77-
oldestdeps: matplotlib==3.1.*
77+
oldestdeps: matplotlib==3.2.*
7878
oldestdeps: asdf==2.10.0
7979
oldestdeps: scipy==1.5.*
8080
oldestdeps: pyyaml==3.13

0 commit comments

Comments
 (0)