Skip to content

Commit

Permalink
Improved calibration_data test coverage.
Browse files Browse the repository at this point in the history
  • Loading branch information
hpparvi committed Nov 29, 2024
1 parent db5d5ad commit 6731847
Show file tree
Hide file tree
Showing 3 changed files with 26 additions and 2 deletions.
4 changes: 2 additions & 2 deletions specreduce/calibration_data.py
Original file line number Diff line number Diff line change
Expand Up @@ -353,13 +353,13 @@ def __init__(
extinction,
u.MagUnit(u.dimensionless_unscaled)
).to(u.dimensionless_unscaled) # Spectrum1D wants this to be linear
if isinstance(extinction, (u.LogUnit, u.Magnitude)) or extinction.unit == u.mag:
elif isinstance(extinction, (u.LogUnit, u.Magnitude)) or extinction.unit == u.mag:
# if in log or magnitudes, recast into Magnitude with dimensionless physical units
extinction = u.Magnitude(
extinction.value,
u.MagUnit(u.dimensionless_unscaled)
).to(u.dimensionless_unscaled)
if extinction.unit != u.dimensionless_unscaled:
elif extinction.unit != u.dimensionless_unscaled:
# if we're given something linear that's not dimensionless_unscaled,
# it's an error
msg = "Input extinction must have unscaled dimensionless units."
Expand Down
9 changes: 9 additions & 0 deletions specreduce/tests/test_linelists.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,15 @@ def test_pypeit_comma_list():
assert "NeI" in line_tab['ion']


@pytest.mark.remote_data
def test_pypeit_nonexisting_lamp():
"""
Test to make sure a warning is raised if the lamp list includes a bad lamp name.
"""
with pytest.warns(UserWarning, match='NeJ not in the list'):
line_tab = load_pypeit_calibration_lines(["HeI", "NeJ"], cache=True, show_progress=False)


@pytest.mark.remote_data
def test_pypeit_empty():
"""
Expand Down
15 changes: 15 additions & 0 deletions specreduce/tests/test_specphot_stds.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,5 @@
from urllib.error import URLError

import pytest
from astropy.utils.exceptions import AstropyUserWarning

Expand All @@ -11,6 +13,12 @@ def test_load_MAST():
assert len(sp.spectral_axis) > 0


@pytest.mark.remote_data
def test_load_MAST_bad_filename():
with pytest.warns(AstropyUserWarning, match="Downloading of"):
sp = load_MAST_calspec("j191b2b_005.fits", show_progress=False)


@pytest.mark.remote_data
def test_load_onedstds():
sp = load_onedstds()
Expand All @@ -23,3 +31,10 @@ def test_load_onedstds_bad_dataset():
with pytest.warns(AstropyUserWarning, match="Specfied dataset,"):
sp = load_onedstds("snffactory")
assert sp is None


@pytest.mark.remote_data
def test_load_onedstds_bad_specfile():
with pytest.warns(AstropyUserWarning, match="Can't load"):
sp = load_onedstds(specfile="FG131.dat")
assert sp is None

0 comments on commit 6731847

Please sign in to comment.