Skip to content

Commit f1d204e

Browse files
authored
Merge pull request #3767 from neutrinoceros/stability_backports
REL: manual backports to yt-4.0.x for stability
2 parents 6884299 + 67d99a6 commit f1d204e

7 files changed

Lines changed: 59 additions & 40 deletions

File tree

conftest.py

Lines changed: 32 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,10 @@
44
from importlib.util import find_spec
55
from pathlib import Path
66

7+
import matplotlib
78
import pytest
89
import yaml
10+
from packaging.version import Version
911

1012
from yt.config import ytcfg
1113
from yt.utilities.answer_testing.testing_utilities import (
@@ -17,6 +19,8 @@
1719
data_dir_load,
1820
)
1921

22+
MPL_VERSION = Version(matplotlib.__version__)
23+
2024

2125
def pytest_addoption(parser):
2226
"""
@@ -109,38 +113,31 @@ def pytest_configure(config):
109113
):
110114
config.addinivalue_line("filterwarnings", value)
111115

112-
# at the time of writing, astropy's wheels are behind numpy's latest
113-
# version but this doesn't cause actual problems in our test suite, so
114-
# we allow this warning to pass.
115-
# last checked with astropy 4.2.1
116-
config.addinivalue_line(
117-
"filterwarnings",
118-
(
119-
"ignore:numpy.ndarray size changed, may indicate binary incompatibility. "
120-
"Expected 80 from C header, got 88 from PyObject:RuntimeWarning"
121-
),
122-
)
123-
if find_spec("astropy") is not None:
124-
# astropy triggers this warning from itself, there's not much we can do on our side
125-
# last checked with astropy 4.2.1
116+
if MPL_VERSION < Version("3.0.0"):
126117
config.addinivalue_line(
127-
"filterwarnings", "ignore::astropy.wcs.wcs.FITSFixedWarning"
118+
"filterwarnings",
119+
(
120+
"ignore:Using or importing the ABCs from 'collections' instead of from 'collections.abc' "
121+
"is deprecated since Python 3.3,and in 3.9 it will stop working:DeprecationWarning"
122+
),
128123
)
129124

130-
if find_spec("cartopy") is not None:
131-
# cartopy still triggers this numpy warning
132-
# last checked wtih cartopy 0.19.0
125+
if find_spec("astropy") is not None:
126+
# at the time of writing, astropy's wheels are behind numpy's latest
127+
# version but this doesn't cause actual problems in our test suite
128+
# last updated with astropy 5.0 + numpy 1.22 + pytest 6.2.5
133129
config.addinivalue_line(
134130
"filterwarnings",
135131
(
136-
"ignore:`np.float` is a deprecated alias for the builtin `float`. "
137-
"To silence this warning, use `float` by itself. "
138-
"Doing this will not modify any behavior and is safe. "
139-
"If you specifically wanted the numpy scalar type, use `np.float64` here."
140-
":DeprecationWarning: "
132+
"ignore:numpy.ndarray size changed, may indicate binary incompatibility. Expected "
133+
r"(80 from C header, got 88|88 from C header, got 96|80 from C header, got 96)"
134+
" from PyObject:RuntimeWarning"
141135
),
142136
)
143-
# this warning *still* shows up on cartopy 0.19 so we'll ignore it
137+
138+
if find_spec("cartopy") is not None:
139+
# This can be removed when cartopy 0.21 is released
140+
# see https://github.com/SciTools/cartopy/pull/1957
144141
config.addinivalue_line(
145142
"filterwarnings",
146143
(
@@ -158,6 +155,17 @@ def pytest_configure(config):
158155
),
159156
)
160157

158+
if find_spec("xarray") is not None:
159+
# this can be removed when upstream issue is closed and a fix published
160+
# https://github.com/pydata/xarray/issues/6092
161+
config.addinivalue_line(
162+
"filterwarnings",
163+
(
164+
"ignore:distutils Version classes are deprecated. "
165+
"Use packaging.version instead.:DeprecationWarning"
166+
),
167+
)
168+
161169

162170
def pytest_collection_modifyitems(config, items):
163171
r"""

setup.cfg

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,7 @@ full =
9292
requests>=2.20.0
9393
scipy>=1.5.0
9494
xarray>=0.16.1
95+
glue-core!=1.2.4;python_version >= '3.10' # see https://github.com/glue-viz/glue/issues/2263
9596
mapserver =
9697
bottle
9798
minimal =

tests/cartopy_requirements.txt

Lines changed: 0 additions & 5 deletions
This file was deleted.

tests/ci_install.sh

Lines changed: 13 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -16,13 +16,7 @@ osx|macOS)
1616
sudo mkdir -p /usr/local/man
1717
sudo chown -R "${USER}:admin" /usr/local/man
1818
brew update
19-
# proj can be unpinned when upstream incompatibility issue is resolved. See
20-
# https://github.com/SciTools/cartopy/issues/1140
21-
export LDFLAGS="$LDFLAGS -L/usr/local/opt/proj@7/lib"
22-
export CPPFLAGS="$CPPFLAGS -I/usr/local/opt/proj@7/include"
23-
export CFLAGS="$CFLAGS -I/usr/local/opt/proj@7/include"
24-
export PKG_CONFIG_PATH="$PKG_CONFIG_PATH:/usr/local/opt/proj@7/lib/pkgconfig"
25-
HOMEBREW_NO_AUTO_UPDATE=1 brew install hdf5 proj@7 geos open-mpi netcdf ccache
19+
HOMEBREW_NO_AUTO_UPDATE=1 brew install hdf5 proj geos open-mpi netcdf ccache
2620
;;
2721
esac
2822

@@ -42,6 +36,18 @@ if [[ "${RUNNER_OS}" == "Windows" ]] && [[ ${dependencies} != "minimal" ]]; then
4236
else
4337
python -m pip install --upgrade pip
4438
python -m pip install --upgrade wheel
39+
40+
# // band aid
41+
# TODO: revert https://github.com/yt-project/yt/pull/3733
42+
# when the following upstream PR is released
43+
# https://github.com/mpi4py/mpi4py/issues/160
44+
45+
# workaround taken from
46+
# https://github.com/mpi4py/mpi4py/issues/157#issuecomment-1001022274
47+
export SETUPTOOLS_USE_DISTUTILS=stdlib
48+
python -m pip install mpi4py
49+
# // end band aid
50+
4551
python -m pip install --upgrade setuptools
4652
fi
4753

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
numpy>=1.19.4
22
cython>=0.29.21,<3.0
3-
cartopy~=0.18.0
3+
cartopy>=0.20.1
44
h5py~=3.1.0
55
matplotlib!=3.4.2,>=2.1.0 # keep in sync with setup.cfg
66
scipy~=1.5.0

yt/utilities/answer_testing/framework.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -842,8 +842,8 @@ def compare_image_lists(new_result, old_result, decimals):
842842
num_images = len(old_result)
843843
assert num_images > 0
844844
for i in range(num_images):
845-
expected = np.loads(zlib.decompress(old_result[i]))
846-
actual = np.loads(zlib.decompress(new_result[i]))
845+
expected = pickle.loads(zlib.decompress(old_result[i]))
846+
actual = pickle.loads(zlib.decompress(new_result[i]))
847847
expected_p, actual_p = ensure_image_comparability(expected, actual)
848848

849849
mpimg.imsave(fns[0], expected_p)

yt/visualization/base_plot_types.py

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,16 @@ def _init_image(self, data, cbnorm, cblinthresh, cmap, extent, aspect):
269269
# instances. It is left as a historical note because we will
270270
# eventually need some form of it.
271271
# self.axes.set_extent(extent)
272-
pass
272+
273+
# possibly related issue (operation order dependency)
274+
# https://github.com/SciTools/cartopy/issues/1468
275+
276+
# in cartopy 0.19 (or 0.20), some intented behaviour changes produced an
277+
# incompatibility here where default values for extent would lead to a crash.
278+
# A solution is to let the transform object set the image extents internally
279+
# see https://github.com/SciTools/cartopy/issues/1955
280+
extent = None
281+
273282
self.image = self.axes.imshow(
274283
data.to_ndarray(),
275284
origin="lower",

0 commit comments

Comments
 (0)