Skip to content

Commit

Permalink
Nitpicks
Browse files Browse the repository at this point in the history
  • Loading branch information
pllim committed Mar 17, 2023
1 parent c3668bd commit 9db225c
Show file tree
Hide file tree
Showing 4 changed files with 12 additions and 17 deletions.
2 changes: 1 addition & 1 deletion setup.cfg
Original file line number Diff line number Diff line change
Expand Up @@ -23,8 +23,8 @@ install_requires =
gwcs>=0.18
asdf-astropy>=0.3
asdf>=2.14
jsonschema<4.18;asdf<2.15
ndcube>=2.0
jsonschema<4.18

[options.extras_require]
test =
Expand Down
4 changes: 1 addition & 3 deletions specutils/io/asdf/converters.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,4 @@
"""
Contains classes that serialize spectral data types into ASDF representations.
"""
"""Contains classes that serialize spectral data types into ASDF representations."""
from asdf.extension import Converter
from asdf_astropy.converters import SpectralCoordConverter
from astropy.nddata import (StdDevUncertainty, VarianceUncertainty,
Expand Down
Original file line number Diff line number Diff line change
@@ -1,11 +1,11 @@
"""Helpers for testing specutils objects in ASDF files.
These are similar to those in ``asdf_astropy.testing.helpers``.
"""
from astropy.tests.helper import assert_quantity_allclose
from asdf_astropy.testing.helpers import assert_spectral_coord_equal
from astropy.tests.helper import assert_quantity_allclose
from numpy.testing import assert_allclose

__all__ = ["assert_spectrum1d_equal", "assert_spectrumlist_equal"]
__all__ = ["assert_spectral_axis_equal", "assert_spectrum1d_equal", "assert_spectrumlist_equal"]


def assert_spectral_axis_equal(a, b):
Expand Down
19 changes: 8 additions & 11 deletions specutils/io/asdf/tests/test_spectra.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,21 @@
from astropy.nddata import StdDevUncertainty

from specutils import Spectrum1D, SpectrumList, SpectralAxis
from specutils.io.asdf.helpers import (
from specutils.io.asdf.tests.helpers import (
assert_spectrum1d_equal, assert_spectrumlist_equal, assert_spectral_axis_equal)


def create_spectrum1d(xmin, xmax, uncertainty=None):
flux = np.ones(xmax - xmin) * u.Jy
wavelength = np.arange(xmin, xmax) * u.AA
wavelength = np.arange(xmin, xmax) * u.nm
uncertainty = StdDevUncertainty(np.ones(xmax - xmin) * u.Jy) if uncertainty is not None else None
return Spectrum1D(spectral_axis=wavelength, flux=flux, uncertainty=uncertainty)


@pytest.mark.parametrize('uncertainty', [False, True])
@pytest.mark.filterwarnings("ignore:.*The unit 'Angstrom' has been deprecated.*")
def test_asdf_spectrum1d(tmp_path, uncertainty):
file_path = tmp_path / "test.asdf"
spectrum = create_spectrum1d(5100, 5300, uncertainty=uncertainty)
spectrum = create_spectrum1d(510, 530, uncertainty=uncertainty)
with asdf.AsdfFile() as af:
af["spectrum"] = spectrum
af.write_to(file_path)
Expand All @@ -30,10 +29,9 @@ def test_asdf_spectrum1d(tmp_path, uncertainty):
assert_spectrum1d_equal(af["spectrum"], spectrum)


@pytest.mark.filterwarnings("ignore:.*The unit 'Angstrom' has been deprecated.*")
def test_asdf_spectralaxis(tmp_path):
file_path = tmp_path / "test.asdf"
wavelengths = np.arange(5100, 5300) * u.AA
wavelengths = np.arange(510, 530) * u.nm
spectral_axis = SpectralAxis(wavelengths, bin_specification="edges")

with asdf.AsdfFile() as af:
Expand All @@ -44,14 +42,13 @@ def test_asdf_spectralaxis(tmp_path):
assert_spectral_axis_equal(af["spectral_axis"], spectral_axis)


@pytest.mark.filterwarnings("ignore:.*The unit 'Angstrom' has been deprecated.*")
def test_asdf_spectrumlist(tmp_path):
file_path = tmp_path / "test.asdf"
spectra = SpectrumList([
create_spectrum1d(5100, 5300),
create_spectrum1d(5000, 5500),
create_spectrum1d(0, 100),
create_spectrum1d(1, 5)
create_spectrum1d(510, 530),
create_spectrum1d(500, 550),
create_spectrum1d(0, 10),
create_spectrum1d(0.1, 0.5)
])
with asdf.AsdfFile() as af:
af["spectrum_list"] = spectra
Expand Down

0 comments on commit 9db225c

Please sign in to comment.