From 3001b39025b4bab90a8302347cb6392e7cac7d79 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Sep 2024 17:03:54 -0400 Subject: [PATCH 1/4] use shorter string for NOSTR value --- src/roman_datamodels/maker_utils/_base.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/roman_datamodels/maker_utils/_base.py b/src/roman_datamodels/maker_utils/_base.py index 822118bf..70c7aecf 100644 --- a/src/roman_datamodels/maker_utils/_base.py +++ b/src/roman_datamodels/maker_utils/_base.py @@ -1,7 +1,7 @@ import asdf NONUM = -999999 -NOSTR = "dummy value" +NOSTR = "?" MESSAGE = "This function assumes shape is 2D, but it was given at least 3 dimensions" From 43668c1ba567d68b4fb778d07db44b62c52af4f8 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Sep 2024 17:09:58 -0400 Subject: [PATCH 2/4] remove magic values from tests --- tests/test_stnode.py | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) diff --git a/tests/test_stnode.py b/tests/test_stnode.py index a2e0a14f..0cf72022 100644 --- a/tests/test_stnode.py +++ b/tests/test_stnode.py @@ -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 NONUM, NOSTR from roman_datamodels.testing import assert_node_equal, assert_node_is_copy, wraps_hashable from .conftest import MANIFEST @@ -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 = { @@ -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 == NOSTR elif isinstance(mdl, (datamodels.SegmentationMapModel, datamodels.SourceCatalogModel)): assert mdl.meta.optical_element == "F158" else: From e2955cbc999f46575d57a929ee4ddbf033348f59 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Sep 2024 17:11:58 -0400 Subject: [PATCH 3/4] add changelog fragment --- changes/388.bugfix.rst | 1 + 1 file changed, 1 insertion(+) create mode 100644 changes/388.bugfix.rst diff --git a/changes/388.bugfix.rst b/changes/388.bugfix.rst new file mode 100644 index 00000000..ebe41a5b --- /dev/null +++ b/changes/388.bugfix.rst @@ -0,0 +1 @@ +Use a shorter string "?" for maker_utils default values for strings. From 7030febb9efe476118faaba3b20bd76dc52f8a55 Mon Sep 17 00:00:00 2001 From: Brett Date: Fri, 20 Sep 2024 18:05:21 -0400 Subject: [PATCH 4/4] Use different value for filename --- src/roman_datamodels/maker_utils/_base.py | 1 + src/roman_datamodels/maker_utils/_basic_meta.py | 4 ++-- tests/test_stnode.py | 4 ++-- 3 files changed, 5 insertions(+), 4 deletions(-) diff --git a/src/roman_datamodels/maker_utils/_base.py b/src/roman_datamodels/maker_utils/_base.py index 70c7aecf..77193ad8 100644 --- a/src/roman_datamodels/maker_utils/_base.py +++ b/src/roman_datamodels/maker_utils/_base.py @@ -2,6 +2,7 @@ NONUM = -999999 NOSTR = "?" +NOFN = "none" MESSAGE = "This function assumes shape is 2D, but it was given at least 3 dimensions" diff --git a/src/roman_datamodels/maker_utils/_basic_meta.py b/src/roman_datamodels/maker_utils/_basic_meta.py index b4d8d0bc..4aa395f7 100644 --- a/src/roman_datamodels/maker_utils/_basic_meta.py +++ b/src/roman_datamodels/maker_utils/_basic_meta.py @@ -2,7 +2,7 @@ from roman_datamodels import stnode -from ._base import NOSTR +from ._base import NOFN, NOSTR def mk_calibration_software_version(**kwargs): @@ -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): diff --git a/tests/test_stnode.py b/tests/test_stnode.py index 0cf72022..c2e3906b 100644 --- a/tests/test_stnode.py +++ b/tests/test_stnode.py @@ -10,7 +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 NONUM, NOSTR +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 @@ -375,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 == NOSTR + assert mdl.meta.filename == NOFN elif isinstance(mdl, (datamodels.SegmentationMapModel, datamodels.SourceCatalogModel)): assert mdl.meta.optical_element == "F158" else: