Skip to content

Commit

Permalink
add unit test for unit round tripping
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Dec 7, 2023
1 parent a2ad963 commit 0030c28
Showing 1 changed file with 16 additions and 1 deletion.
17 changes: 16 additions & 1 deletion src/stdatamodels/jwst/datamodels/tests/test_fits.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
import pytest

from stdatamodels.jwst import datamodels
from stdatamodels.jwst.datamodels import ImageModel, JwstDataModel, RampModel
from stdatamodels.jwst.datamodels import ImageModel, JwstDataModel, RampModel, SpecModel


@pytest.fixture
Expand Down Expand Up @@ -91,3 +91,18 @@ def test_resave_duplication_bug(tmp_path):

with fits.open(fn1) as ff1, fits.open(fn2) as ff2:
assert ff1['ASDF'].size == ff2['ASDF'].size


def test_units_roundtrip(tmp_path):
m = SpecModel()
# this next line is required for stdatamodels to cast
# spec_table to a FITS_rec (similar to having data assigned
# to the attribute)
m.spec_table = m.spec_table
m.spec_table.columns['WAVELENGTH'].unit = 'nm'

fn = tmp_path / "test1.fits"
m.save(fn)

m = datamodels.open(fn)
assert m.spec_table.columns['WAVELENGTH'].unit == 'nm'

0 comments on commit 0030c28

Please sign in to comment.