Skip to content

Commit

Permalink
Merge pull request #2656 from pllim/handle-modeling-warn-pytest-8
Browse files Browse the repository at this point in the history
TST: Handle second warning in test_all_nan_uncert_subset
  • Loading branch information
pllim authored Jan 8, 2024
2 parents 03edac6 + 4e218ac commit 410d2f2
Showing 1 changed file with 11 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,14 @@
"""
import warnings
import pytest
from contextlib import nullcontext

import numpy as np
from numpy.testing import assert_allclose

from astropy.nddata import StdDevUncertainty
from astropy.utils.exceptions import AstropyUserWarning
from astropy.utils.introspection import minversion
import astropy.units as u

from glue.core.roi import CircularROI, XRangeROI
Expand All @@ -18,6 +20,8 @@
from jdaviz.configs.cubeviz.plugins.tests.test_parsers import ASTROPY_LT_5_3
from jdaviz.configs.default.plugins.model_fitting.initializers import MODELS

PYTEST_LT_8_0 = not minversion(pytest, "8.0.dev")


def test_default_model_labels(specviz_helper, spectrum1d):
specviz_helper.load_data(spectrum1d)
Expand Down Expand Up @@ -427,7 +431,13 @@ def test_all_nan_uncert_subset(specviz_helper):
plugin = specviz_helper.plugins['Model Fitting']
plugin.create_model_component('Linear1D')

with pytest.warns(AstropyUserWarning, match='Model is linear in parameters'):
if PYTEST_LT_8_0:
ctx = nullcontext()
else:
ctx = pytest.warns(
AstropyUserWarning, match="Non-Finite input data has been removed by the fitter")

with pytest.warns(AstropyUserWarning, match='Model is linear in parameters'), ctx:
plugin.calculate_fit()

# check that slope and intercept are fit correctly to just the first 2
Expand Down

0 comments on commit 410d2f2

Please sign in to comment.