Skip to content

TST: Ignore RuntimeWarning from scipy 1.6.0 - #11201

Merged
pllim merged 1 commit into
astropy:masterfrom
pllim:fix-ci-scipy-1.6.0
Dec 31, 2020
Merged

pllim merged 1 commit into
astropy:masterfrom
pllim:fix-ci-scipy-1.6.0

Conversation

@pllim

@pllim pllim commented Dec 31, 2020 •

Copy link
Copy Markdown
Member

Description

This pull request is to ignore a new warning that appears in some fitter tests with the release of Scipy 1.6.0. I am ignoring them because they are blocking CI for unrelated PRs.

================================== FAILURES ===================================
_______ TestNonLinearFitters.test_fitter_against_LevMar[SLSQPLSQFitter] _______

self = <astropy.modeling.tests.test_fitters.TestNonLinearFitters object at 0x00000214A13BFC40>
fitter_class = <class 'astropy.modeling.fitting.SLSQPLSQFitter'>

    @pytest.mark.filterwarnings(r'ignore:.* Maximum number of iterations reached')
    @pytest.mark.parametrize('fitter_class', fitters)
    def test_fitter_against_LevMar(self, fitter_class):
        """Tests results from non-linear fitters against `LevMarLSQFitter`."""
    
        levmar = LevMarLSQFitter()
        fitter = fitter_class()
        # This emits a warning from fitter that we need to ignore with
        # pytest.mark.filterwarnings above.
>       new_model = fitter(self.gauss, self.xdata, self.ydata)

..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\tests\test_fitters.py:452: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:263: in wrapper
    return func(self, model, x, y, z=z, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:1308: in __call__
    fitparams, self.fit_info = self._opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\optimizers.py:159: in __call__
    fitparams, final_func_val, numiter, exit_mode, mess = self.opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:207: in fmin_slsqp
    res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds,
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:433: in _minimize_slsqp
    fx = wrapped_fun(x)
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:274: in eval
    x = _check_clip_x(x, bounds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = array([243.15297506,   4.9492131 ,   0.        ])
bounds = (array([-1.00000000e+12, -1.00000000e+12,  1.17549435e-38]), array([1.e+12, 1.e+12, 1.e+12]))

    def _check_clip_x(x, bounds):
        if (x < bounds[0]).any() or (x > bounds[1]).any():
>           warnings.warn("Values in x were outside bounds during a "
                          "minimize step, clipping to bounds", RuntimeWarning)
E           RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds

..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:282: RuntimeWarning
____________ TestNonLinearFitters.test_LSQ_SLSQP_with_constraints _____________

self = <astropy.modeling.tests.test_fitters.TestNonLinearFitters object at 0x00000214A0E79340>

    def test_LSQ_SLSQP_with_constraints(self):
        """
        Runs `LevMarLSQFitter` and `SLSQPLSQFitter` on a model with
        constraints.
        """
    
        g1 = models.Gaussian1D(100, 5, stddev=1)
        g1.mean.fixed = True
        fitter = LevMarLSQFitter()
        fslsqp = SLSQPLSQFitter()
>       slsqp_model = fslsqp(g1, self.xdata, self.ydata)

..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\tests\test_fitters.py:467: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:263: in wrapper
    return func(self, model, x, y, z=z, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:1308: in __call__
    fitparams, self.fit_info = self._opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\optimizers.py:159: in __call__
    fitparams, final_func_val, numiter, exit_mode, mess = self.opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:207: in fmin_slsqp
    res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds,
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:433: in _minimize_slsqp
    fx = wrapped_fun(x)
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:274: in eval
    x = _check_clip_x(x, bounds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = array([242.40174527,   0.        ])
bounds = (array([-1.00000000e+12,  1.17549435e-38]), array([1.e+12, 1.e+12]))

    def _check_clip_x(x, bounds):
        if (x < bounds[0]).any() or (x > bounds[1]).any():
>           warnings.warn("Values in x were outside bounds during a "
                          "minimize step, clipping to bounds", RuntimeWarning)
E           RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds

..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:282: RuntimeWarning
______ Test1DFittingWithOutlierRemoval.test_with_fitters_and_sigma_clip _______

self = <astropy.modeling.tests.test_fitters.Test1DFittingWithOutlierRemoval object at 0x00000214A0A10D00>

    @pytest.mark.filterwarnings('ignore:The fit may be unsuccessful')
    def test_with_fitters_and_sigma_clip(self):
        import scipy.stats as stats
    
        np.random.seed(0)
        c = stats.bernoulli.rvs(0.25, size=self.x.shape)
        self.y += (np.random.normal(0., 0.2, self.x.shape) +
                   c*np.random.normal(3.0, 5.0, self.x.shape))
    
        g_init = models.Gaussian1D(amplitude=1., mean=0, stddev=1.)
        # test with Levenberg-Marquardt Least Squares fitter
        fit = FittingWithOutlierRemoval(LevMarLSQFitter(), sigma_clip,
                                        niter=3, sigma=3.0)
        fitted_model, _ = fit(g_init, self.x, self.y)
        assert_allclose(fitted_model.parameters, self.model_params, rtol=1e-1)
        # test with Sequential Least Squares Programming fitter
        fit = FittingWithOutlierRemoval(SLSQPLSQFitter(), sigma_clip,
                                        niter=3, sigma=3.0)
>       fitted_model, _ = fit(g_init, self.x, self.y)

..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\tests\test_fitters.py:644: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:923: in __call__
    fitted_model = self.fitter(model, x, y, z, weights=weights, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:263: in wrapper
    return func(self, model, x, y, z=z, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:1308: in __call__
    fitparams, self.fit_info = self._opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\optimizers.py:159: in __call__
    fitparams, final_func_val, numiter, exit_mode, mess = self.opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:207: in fmin_slsqp
    res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds,
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:433: in _minimize_slsqp
    fx = wrapped_fun(x)
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:274: in eval
    x = _check_clip_x(x, bounds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = array([ 4.15448194, -2.8654803 ,  0.        ])
bounds = (array([-1.00000000e+12, -1.00000000e+12,  1.17549435e-38]), array([1.e+12, 1.e+12, 1.e+12]))

    def _check_clip_x(x, bounds):
        if (x < bounds[0]).any() or (x > bounds[1]).any():
>           warnings.warn("Values in x were outside bounds during a "
                          "minimize step, clipping to bounds", RuntimeWarning)
E           RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds

..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:282: RuntimeWarning
______ Test2DFittingWithOutlierRemoval.test_with_fitters_and_sigma_clip _______

self = <astropy.modeling.tests.test_fitters.Test2DFittingWithOutlierRemoval object at 0x00000214A0F4A820>

    @pytest.mark.filterwarnings('ignore:The fit may be unsuccessful')
    def test_with_fitters_and_sigma_clip(self):
        import scipy.stats as stats
    
        np.random.seed(0)
        c = stats.bernoulli.rvs(0.25, size=self.z.shape)
        self.z += (np.random.normal(0., 0.2, self.z.shape) +
                   c*np.random.normal(self.z, 2.0, self.z.shape))
    
        guess = self.initial_guess(self.z, np.array([self.y, self.x]))
        g2_init = models.Gaussian2D(amplitude=guess[0], x_mean=guess[1],
                                    y_mean=guess[2], x_stddev=0.75,
                                    y_stddev=1.25)
    
        # test with Levenberg-Marquardt Least Squares fitter
        fit = FittingWithOutlierRemoval(LevMarLSQFitter(), sigma_clip,
                                        niter=3, sigma=3.)
        fitted_model, _ = fit(g2_init, self.x, self.y, self.z)
        assert_allclose(fitted_model.parameters[0:5], self.model_params,
                        atol=1e-1)
        # test with Sequential Least Squares Programming fitter
        fit = FittingWithOutlierRemoval(SLSQPLSQFitter(), sigma_clip, niter=3,
                                        sigma=3.)
>       fitted_model, _ = fit(g2_init, self.x, self.y, self.z)

..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\tests\test_fitters.py:710: 
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:923: in __call__
    fitted_model = self.fitter(model, x, y, z, weights=weights, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:263: in wrapper
    return func(self, model, x, y, z=z, **kwargs)
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\fitting.py:1308: in __call__
    fitparams, self.fit_info = self._opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\astropy\modeling\optimizers.py:159: in __call__
    fitparams, final_func_val, numiter, exit_mode, mess = self.opt_method(
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:207: in fmin_slsqp
    res = _minimize_slsqp(func, x0, args, jac=fprime, bounds=bounds,
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\slsqp.py:433: in _minimize_slsqp
    fx = wrapped_fun(x)
..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:274: in eval
    x = _check_clip_x(x, bounds)
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _

x = array([-565.15362854, -915.72898196, -285.2617742 ,    0.        ,
          0.        ,  201.04907227])
bounds = (array([-1.00000000e+12, -1.00000000e+12, -1.00000000e+12,  1.17549435e-38,
        1.17549435e-38, -1.00000000e+12]), array([1.e+12, 1.e+12, 1.e+12, 1.e+12, 1.e+12, 1.e+12]))

    def _check_clip_x(x, bounds):
        if (x < bounds[0]).any() or (x > bounds[1]).any():
>           warnings.warn("Values in x were outside bounds during a "
                          "minimize step, clipping to bounds", RuntimeWarning)
E           RuntimeWarning: Values in x were outside bounds during a minimize step, clipping to bounds

..\..\.tox\py38-test-alldeps\lib\site-packages\scipy\optimize\optimize.py:282: RuntimeWarning

@pllim
pllim merged commit 72ca3c0 into astropy:master Dec 31, 2020
@pllim
pllim deleted the fix-ci-scipy-1.6.0 branch December 31, 2020 19:40
astrofrog pushed a commit that referenced this pull request Mar 16, 2021
TST: Ignore RuntimeWarning from scipy 1.6.0
@embray embray mentioned this pull request Mar 18, 2021
5 tasks done
eteq pushed a commit that referenced this pull request Mar 25, 2021
TST: Ignore RuntimeWarning from scipy 1.6.0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants