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