Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update matplotlib requirement from <=3.9.3,>=3.5.0 to >=3.5.0,<=3.10.0 #1470

Merged
merged 11 commits into from
Jan 27, 2025
Merged
40 changes: 13 additions & 27 deletions .github/workflows/mpl_tests.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,29 +12,8 @@ jobs:
strategy:
fail-fast: false
matrix:
mpl-version: [3.0.0]
mpl-version: [3.5.0]
include:
- mpl-version: 3.0.0
- mpl-version: 3.0.1
- mpl-version: 3.0.2
- mpl-version: 3.0.3
- mpl-version: 3.1.0
- mpl-version: 3.1.1
- mpl-version: 3.1.2
- mpl-version: 3.1.3
- mpl-version: 3.2.0
- mpl-version: 3.2.1
- mpl-version: 3.2.2
- mpl-version: 3.3.0
- mpl-version: 3.3.1
- mpl-version: 3.3.2
- mpl-version: 3.3.3
- mpl-version: 3.3.4
- mpl-version: 3.4.0
- mpl-version: 3.4.1
- mpl-version: 3.4.2
- mpl-version: 3.4.3
- mpl-version: 3.5.0
- mpl-version: 3.5.1
- mpl-version: 3.5.2
- mpl-version: 3.5.3
Expand All @@ -55,6 +34,8 @@ jobs:
- mpl-version: 3.8.4
- mpl-version: 3.9.0
- mpl-version: 3.9.2
- mpl-version: 3.9.3
- mpl-version: 3.10.0

steps:
- uses: actions/checkout@v4
Expand All @@ -63,14 +44,19 @@ jobs:
with:
python-version: '3.10'
cache: pip
- name: Install dependencies
- name: Install dependencies with given Matplotlib version
run: |
python -m pip install --upgrade pip
pip install -r devtools/dev-requirements.txt
pip install "matplotlib==${{ matrix.mpl-version }}"
- name: Test with pytest
sed -i '/matplotlib/d' ./requirements.txt
sed -i '1i\matplotlib == ${{ matrix.mpl-version }}' ./requirements.txt
cat ./requirements.txt
pip install -r ./devtools/dev-requirements.txt

- name: Action Details
run: |
pwd
lscpu
pip list

- name: Test with pytest
run: |
python -m pytest tests/test_plotting.py --durations=0 --mpl --maxfail=1
10 changes: 8 additions & 2 deletions desc/plotting.py
Original file line number Diff line number Diff line change
Expand Up @@ -110,16 +110,22 @@


def _set_tight_layout(fig):
version = matplotlib.__version__.split(".")
major = int(version[0])
minor = int(version[1])
# compat layer to deal with API changes in mpl 3.6.0
if int(matplotlib.__version__[0]) == 3 and int(matplotlib.__version__[2]) < 6:
if major == 3 and minor < 6:
fig.set_tight_layout(True)
else:
fig.set_layout_engine("tight")


def _get_cmap(name, n=None):
version = matplotlib.__version__.split(".")
major = int(version[0])
minor = int(version[1])

Check warning on line 126 in desc/plotting.py

View check run for this annotation

Codecov / codecov/patch

desc/plotting.py#L124-L126

Added lines #L124 - L126 were not covered by tests
# compat layer to deal with API changes in mpl 3.6.0
if int(matplotlib.__version__[0]) == 3 and int(matplotlib.__version__[2]) < 6:
if major == 3 and minor < 6:

Check warning on line 128 in desc/plotting.py

View check run for this annotation

Codecov / codecov/patch

desc/plotting.py#L128

Added line #L128 was not covered by tests
return matplotlib.cm.get_cmap(name, n)
else:
c = matplotlib.colormaps[name]
Expand Down
2 changes: 1 addition & 1 deletion requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ colorama <= 0.4.6
diffrax >= 0.4.1, <= 0.6.2
h5py >= 3.0.0, <= 3.12.1
interpax >= 0.3.3, <= 0.3.4
matplotlib >= 3.5.0, <= 3.9.3
matplotlib >= 3.5.0, <= 3.10.0
mpmath >= 1.0.0, <= 1.3.0
netcdf4 >= 1.5.4, <= 1.7.2
numpy >= 1.20.0, <= 2.2.2
Expand Down
Loading