Skip to content

Commit

Permalink
avoid an extra validation on __init__
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram committed Nov 4, 2024
1 parent 68116df commit a0af670
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/stdatamodels/jwst/datamodels/tests/test_multislit.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from numpy.testing import assert_array_equal
import pytest

from stdatamodels.jwst.datamodels import MultiSlitModel, ImageModel
from stdatamodels.jwst.datamodels import MultiSlitModel, ImageModel, SlitModel


def test_multislit_model():
Expand Down Expand Up @@ -155,3 +155,12 @@ def test_copy_multislit():

assert model1.slits[0].data[330, 330] == 1
assert output.slits[0].data[330, 330] == -1


def test_slit_from_multislit():
model = MultiSlitModel()
slit = SlitModel()
# access int_times so it's created
slit.int_times = slit.int_times
model.slits.append(slit)
slit = SlitModel(model.slits[0].instance)
5 changes: 5 additions & 0 deletions src/stdatamodels/model_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -566,6 +566,11 @@ def open_asdf(init=None,
ignore_unrecognized_tag=ignore_unrecognized_tag,
**kwargs)

elif isinstance(init, dict):
asdffile = AsdfFile(None,
ignore_unrecognized_tag=ignore_unrecognized_tag
)
asdffile._tree = init
else:
asdffile = AsdfFile(init,
ignore_unrecognized_tag=ignore_unrecognized_tag
Expand Down

0 comments on commit a0af670

Please sign in to comment.