From 2417387afefff003b85f29b2ef869be725f7af60 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Sun, 27 Aug 2023 12:22:07 -0400 Subject: [PATCH 1/2] MNT: Pin numpy<2 for v5.3.x --- docs/changes/15234.other.rst | 1 + pyproject.toml | 2 +- setup.cfg | 2 +- tox.ini | 1 - 4 files changed, 3 insertions(+), 3 deletions(-) create mode 100644 docs/changes/15234.other.rst diff --git a/docs/changes/15234.other.rst b/docs/changes/15234.other.rst new file mode 100644 index 00000000000..d0f6d4c2c19 --- /dev/null +++ b/docs/changes/15234.other.rst @@ -0,0 +1 @@ +v5.3.x will not support NumPy 2.0 or later. diff --git a/pyproject.toml b/pyproject.toml index f26ff7e50ab..69d746de871 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -2,7 +2,7 @@ requires = ["setuptools", "setuptools_scm>=6.2", "cython==0.29.34", - "oldest-supported-numpy", + "numpy>=1.25,<2", "extension-helpers"] build-backend = 'setuptools.build_meta' diff --git a/setup.cfg b/setup.cfg index 015f44d4811..040dc520de7 100644 --- a/setup.cfg +++ b/setup.cfg @@ -28,7 +28,7 @@ packages = find: zip_safe = False tests_require = pytest-astropy install_requires = - numpy>=1.21 + numpy>=1.21,<2 pyerfa>=2.0 PyYAML>=3.13 packaging>=19.0 diff --git a/tox.ini b/tox.ini index 09ed7a6a1c3..d20518cf5da 100644 --- a/tox.ini +++ b/tox.ini @@ -86,7 +86,6 @@ deps = # or nightly wheel of key dependencies. # Do not install asdf-astropy so we can test astropy.io.misc.asdf until we remove it. devdeps: scipy>=0.0.dev0 - devdeps: numpy>=0.0.dev0 devdeps: matplotlib>=0.0.dev0 devdeps: git+https://github.com/asdf-format/asdf.git#egg=asdf devdeps: git+https://github.com/liberfa/pyerfa.git#egg=pyerfa From 9580b235143e820543b63ce3bc3d17a5e775dd07 Mon Sep 17 00:00:00 2001 From: "P. L. Lim" <2090236+pllim@users.noreply.github.com> Date: Sun, 27 Aug 2023 13:09:32 -0400 Subject: [PATCH 2/2] TST: Update modeling test logic that now fails in devdeps with scipy dev. Since this is backport branch and the warning may or may not appear, let's just blanket ignore the unsuccessful fit because test case is not well defined to begin with. --- astropy/modeling/tests/test_constraints.py | 15 +++------------ 1 file changed, 3 insertions(+), 12 deletions(-) diff --git a/astropy/modeling/tests/test_constraints.py b/astropy/modeling/tests/test_constraints.py index 2ddcf37d607..1e7ac2a3bb8 100644 --- a/astropy/modeling/tests/test_constraints.py +++ b/astropy/modeling/tests/test_constraints.py @@ -14,13 +14,9 @@ from astropy.modeling import fitting, models from astropy.modeling.core import Fittable1DModel from astropy.modeling.parameters import Parameter -from astropy.utils import minversion -from astropy.utils.compat.numpycompat import NUMPY_LT_2_0 from astropy.utils.compat.optional_deps import HAS_SCIPY from astropy.utils.exceptions import AstropyUserWarning -SCIPY_LT_1_11_2 = not minversion("scipy", "1.11.2") if HAS_SCIPY else True - fitters = [ fitting.LevMarLSQFitter, fitting.TRFLSQFitter, @@ -184,6 +180,7 @@ def test_bounds_slsqp(self): assert intercept + 10**-5 >= bounds["intercept"][0] assert intercept - 10**-5 <= bounds["intercept"][1] + @pytest.mark.filterwarnings("ignore:The fit may be unsuccessful") @pytest.mark.parametrize("fitter", fitters) def test_bounds_gauss2d_lsq(self, fitter): fitter = fitter() @@ -205,19 +202,13 @@ def test_bounds_gauss2d_lsq(self, fitter): bounds=bounds, ) if isinstance(fitter, (fitting.LevMarLSQFitter, fitting.DogBoxLSQFitter)): - with pytest.warns(AstropyUserWarning, match="The fit may be unsuccessful"): - model = fitter(gauss, X, Y, self.data) + model = fitter(gauss, X, Y, self.data) else: - ctx2 = nullcontext() if isinstance(fitter, fitting.TRFLSQFitter): ctx = np.errstate(invalid="ignore", divide="ignore") - if not NUMPY_LT_2_0 or not SCIPY_LT_1_11_2: - ctx2 = pytest.warns( - AstropyUserWarning, match="The fit may be unsuccessful" - ) else: ctx = nullcontext() - with ctx, ctx2: + with ctx: model = fitter(gauss, X, Y, self.data) x_mean = model.x_mean.value y_mean = model.y_mean.value