Skip to content

Commit

Permalink
use shorter string for NOSTR value (#388)
Browse files Browse the repository at this point in the history
  • Loading branch information
braingram authored Sep 26, 2024
1 parent 4cdc45d commit 2734f19
Show file tree
Hide file tree
Showing 4 changed files with 19 additions and 16 deletions.
1 change: 1 addition & 0 deletions changes/388.bugfix.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
Use a shorter string "?" for maker_utils default values for strings.
3 changes: 2 additions & 1 deletion src/roman_datamodels/maker_utils/_base.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
import asdf

NONUM = -999999
NOSTR = "dummy value"
NOSTR = "?"
NOFN = "none"

MESSAGE = "This function assumes shape is 2D, but it was given at least 3 dimensions"

Expand Down
4 changes: 2 additions & 2 deletions src/roman_datamodels/maker_utils/_basic_meta.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@

from roman_datamodels import stnode

from ._base import NOSTR
from ._base import NOFN, NOSTR


def mk_calibration_software_version(**kwargs):
Expand Down Expand Up @@ -36,7 +36,7 @@ def mk_filename(**kwargs):
-------
roman_datamodels.stnode.Filename
"""
return stnode.Filename(kwargs.get("filename", NOSTR))
return stnode.Filename(kwargs.get("filename", NOFN))


def mk_file_date(**kwargs):
Expand Down
27 changes: 14 additions & 13 deletions tests/test_stnode.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
from roman_datamodels import maker_utils
from roman_datamodels import maker_utils as utils
from roman_datamodels import stnode, validate
from roman_datamodels.maker_utils._base import NOFN, NONUM, NOSTR
from roman_datamodels.testing import assert_node_equal, assert_node_is_copy, wraps_hashable

from .conftest import MANIFEST
Expand Down Expand Up @@ -351,20 +352,20 @@ def test_node_representation(model):
if isinstance(mdl, (datamodels.MosaicModel, datamodels.MosaicSegmentationMapModel, datamodels.MosaicSourceCatalogModel)):
assert repr(mdl.meta.basic) == repr(
{
"time_first_mjd": -999999,
"time_last_mjd": -999999,
"time_mean_mjd": -999999,
"max_exposure_time": -999999,
"mean_exposure_time": -999999,
"visit": -999999,
"segment": -999999,
"pass": -999999,
"program": "dummy value",
"survey": "dummy value",
"time_first_mjd": NONUM,
"time_last_mjd": NONUM,
"time_mean_mjd": NONUM,
"max_exposure_time": NONUM,
"mean_exposure_time": NONUM,
"visit": NONUM,
"segment": NONUM,
"pass": NONUM,
"program": NOSTR,
"survey": NOSTR,
"optical_element": "F158",
"instrument": "WFI",
"location_name": "dummy value",
"product_type": "dummy value",
"location_name": NOSTR,
"product_type": NOSTR,
}
)
model_types = {
Expand All @@ -374,7 +375,7 @@ def test_node_representation(model):
}
assert mdl.meta.model_type == model_types[type(mdl)]
assert mdl.meta.telescope == "ROMAN"
assert mdl.meta.filename == "dummy value"
assert mdl.meta.filename == NOFN
elif isinstance(mdl, (datamodels.SegmentationMapModel, datamodels.SourceCatalogModel)):
assert mdl.meta.optical_element == "F158"
else:
Expand Down

0 comments on commit 2734f19

Please sign in to comment.