From ffde805bb324698c7692a5568b48a8db014cc8b7 Mon Sep 17 00:00:00 2001 From: Hannu Parviainen Date: Fri, 29 Nov 2024 16:25:37 +0000 Subject: [PATCH] Fixed codestyle errors in calibration_data and its tests. --- specreduce/calibration_data.py | 18 +++++++++++++----- specreduce/tests/test_extinction.py | 3 +-- specreduce/tests/test_linelists.py | 2 +- specreduce/tests/test_specphot_stds.py | 4 +--- 4 files changed, 16 insertions(+), 11 deletions(-) diff --git a/specreduce/calibration_data.py b/specreduce/calibration_data.py index dbf8800..c534fe4 100644 --- a/specreduce/calibration_data.py +++ b/specreduce/calibration_data.py @@ -163,9 +163,12 @@ def load_pypeit_calibration_lines( data_path = f"arc_lines/lists/{lamp}_lines.dat" try: with get_pkg_data_fileobj(data_path, cache=cache) as data_file: - linelists.append(Table.read(data_file.read(), format='ascii.fixed_width', comment='#')) + linelists.append(Table.read(data_file.read(), + format='ascii.fixed_width', + comment='#')) except URLError as e: - warnings.warn(f"Downloading of {data_path} failed: {e}", AstropyUserWarning) + warnings.warn(f"Downloading of {data_path} failed: {e}", + AstropyUserWarning) else: warnings.warn( f"{lamp} not in the list of supported calibration " @@ -220,7 +223,8 @@ def load_MAST_calspec( if filename.exists() and filename.is_file(): file_path = filename else: - with conf.set_temp("dataurl", "https://archive.stsci.edu/hlsps/reference-atlases/cdbs/calspec/"): + with conf.set_temp("dataurl", + "https://archive.stsci.edu/hlsps/reference-atlases/cdbs/calspec/"): try: file_path = get_pkg_data_filename(str(filename), show_progress=show_progress) except URLError as e: @@ -281,7 +285,9 @@ def load_onedstds( try: data_path = str(Path("onedstds") / Path(dataset) / Path(specfile)) with get_pkg_data_fileobj(data_path, cache=cache) as data_file: - t = Table.read(data_file.read(), format="ascii", names=['wavelength', 'ABmag', 'binsize']) + t = Table.read(data_file.read(), + format="ascii", + names=['wavelength', 'ABmag', 'binsize']) except URLError as e: msg = f"Can't load {specfile} from {dataset}: {e}." warnings.warn(msg, AstropyUserWarning) @@ -375,7 +381,9 @@ def __init__( with conf.set_temp("dataurl", SPECREDUCE_DATA_URL): data_path = str(Path("extinction") / Path(f"{model}extinct.dat")) with get_pkg_data_fileobj(data_path, cache=cache) as data_file: - t = Table.read(data_file.read(), format="ascii", names=['wavelength', 'extinction']) + t = Table.read(data_file.read(), + format="ascii", + names=['wavelength', 'extinction']) # the specreduce_data models all provide wavelengths in angstroms spectral_axis = t['wavelength'].data * u.angstrom diff --git a/specreduce/tests/test_extinction.py b/specreduce/tests/test_extinction.py index 1e91582..bbe8f88 100644 --- a/specreduce/tests/test_extinction.py +++ b/specreduce/tests/test_extinction.py @@ -63,7 +63,7 @@ def test_unsupported_model(): Test loading of a nonexistent model """ with pytest.raises(ValueError, match='Requested extinction model,'): - ext = AtmosphericExtinction(model='bad_model') + AtmosphericExtinction(model='bad_model') @pytest.mark.remote_data @@ -75,7 +75,6 @@ def test_missing_extinction_unit(): extinction = 1. / wave with pytest.warns(AstropyUserWarning): ext = AtmosphericExtinction(extinction=extinction, spectral_axis=wave * u.um) - assert len(ext.extinction_mag) > 0 assert len(ext.transmission) > 0 diff --git a/specreduce/tests/test_linelists.py b/specreduce/tests/test_linelists.py index 2bfe6ef..247868c 100644 --- a/specreduce/tests/test_linelists.py +++ b/specreduce/tests/test_linelists.py @@ -49,7 +49,7 @@ 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) + load_pypeit_calibration_lines(["HeI", "NeJ"], cache=True, show_progress=False) @pytest.mark.remote_data diff --git a/specreduce/tests/test_specphot_stds.py b/specreduce/tests/test_specphot_stds.py index 58381c6..b347684 100644 --- a/specreduce/tests/test_specphot_stds.py +++ b/specreduce/tests/test_specphot_stds.py @@ -1,5 +1,3 @@ -from urllib.error import URLError - import pytest from astropy.utils.exceptions import AstropyUserWarning @@ -16,7 +14,7 @@ def test_load_MAST(): @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) + load_MAST_calspec("j191b2b_005.fits", show_progress=False) @pytest.mark.remote_data