Skip to content

Commit

Permalink
[pre-commit.ci] auto fixes from pre-commit.com hooks
Browse files Browse the repository at this point in the history
for more information, see https://pre-commit.ci
  • Loading branch information
pre-commit-ci[bot] committed May 23, 2024
1 parent deb1266 commit b0ef85b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions src/roman_datamodels/datamodels/_datamodels.py
Original file line number Diff line number Diff line change
Expand Up @@ -154,12 +154,13 @@ def from_science_raw(cls, model):
if isinstance(model, cls):
return model
if not isinstance(model, (ScienceRawModel, TvacModel)):
raise ValueError('Input must be one of (RampModel, ScienceRawModel, TvacModel)')
raise ValueError("Input must be one of (RampModel, ScienceRawModel, TvacModel)")

# Create base ramp node with dummy values (for validation)
# from roman_datamodels.maker_utils import mk_ramp
# input_ramp = mk_ramp(shape=model.shape)
from roman_datamodels.maker_utils import mk_datamodel

output_model = mk_datamodel(RampModel, shape=model.shape)

# check if the input model has a resultantdq from SDF
Expand All @@ -174,14 +175,12 @@ def from_science_raw(cls, model):
if key not in output_model:
output_model[key] = model.__getattr__(key)
elif isinstance(output_model[key], dict):
# If a dictionary (like meta), overwrite entires (but keep
# If a dictionary (like meta), overwrite entries (but keep
# required dummy entries that may not be in input_model)
output_model[key].update(model.__getattr__(key))
elif isinstance(output_model[key], np.ndarray):
# Cast input ndarray as RampModel dtype
output_model[key] = model.__getattr__(key).astype(
output_model[key].dtype
)
output_model[key] = model.__getattr__(key).astype(output_model[key].dtype)
else:
output_model[key] = model.__getattr__(key)

Expand Down
2 changes: 1 addition & 1 deletion tests/test_models.py
Original file line number Diff line number Diff line change
Expand Up @@ -960,7 +960,7 @@ def test_datamodel_save_filename(tmp_path):
assert new_ramp.meta.filename == filename.name


@pytest.mark.parametrize('model_class', [datamodels.RampModel, datamodels.ScienceRawModel, datamodels.TvacModel])
@pytest.mark.parametrize("model_class", [datamodels.RampModel, datamodels.ScienceRawModel, datamodels.TvacModel])
def test_rampmodel_from_science_raw(model_class):
"""Test creation of RampModel from raw science/tvac"""
model = utils.mk_datamodel(model_class)
Expand Down

0 comments on commit b0ef85b

Please sign in to comment.