Skip to content

Commit a1a873f

Browse files
committed
fixups from code review
1 parent b6db400 commit a1a873f

File tree

2 files changed

+7
-32
lines changed

2 files changed

+7
-32
lines changed

imas/ids_convert.py

Lines changed: 1 addition & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1157,14 +1157,7 @@ def _circuit_connections_4to3(node: IDSPrimitive) -> None:
11571157

11581158

11591159
def _name_identifier_3to4(source_name: IDSBase, target_description: IDSBase) -> None:
1160-
"""Handle DD3to4 name→description rename, preserving name when identifier is empty.
1161-
1162-
GH#114: The ``name→description`` rename moves DD3 ``name`` to DD4 ``description``.
1163-
Normally DD4 ``name`` is filled by the ``identifier→name`` rename. However, when
1164-
the DD3 ``identifier`` is empty/unset, ``iter_nonempty_`` never visits it, leaving
1165-
DD4 ``name`` blank. This handler copies DD3 ``name`` to *both* DD4 ``description``
1166-
and DD4 ``name`` when the DD3 ``identifier`` is absent.
1167-
"""
1160+
"""Preserve name when identifier is empty, see GH#114."""
11681161
# Always copy DD3 name -> DD4 description
11691162
target_description.value = source_name.value
11701163

imas/test/test_ids_convert.py

Lines changed: 6 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -583,37 +583,19 @@ def test_3to4_name_identifier_empty_identifier():
583583
src.ids_properties.homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS
584584
src.coil.resize(2)
585585
# Case 1: name populated, identifier empty
586-
src.coil[0].name = "CS3U"
586+
src.coil[0].name = "TEST_NAME"
587587
src.coil[0].identifier = ""
588588
# Case 2: name populated, identifier not set at all
589-
src.coil[1].name = "PF1"
589+
src.coil[1].name = "TEST_NAME2"
590590

591591
dst = convert_ids(src, "4.0.0")
592592

593593
# name must be preserved in DD4 name (not overwritten by empty identifier)
594-
assert dst.coil[0].name == "CS3U"
595-
assert dst.coil[0].description == "CS3U"
594+
assert dst.coil[0].name == "TEST_NAME"
595+
assert dst.coil[0].description == "TEST_NAME"
596596

597-
assert dst.coil[1].name == "PF1"
598-
assert dst.coil[1].description == "PF1"
599-
600-
601-
def test_3to4_name_identifier_both_populated():
602-
"""GH#114: when both name and identifier are populated, identifier wins."""
603-
factory = IDSFactory("3.40.1")
604-
605-
src = factory.pf_active()
606-
src.ids_properties.homogeneous_time = IDS_TIME_MODE_HOMOGENEOUS
607-
src.coil.resize(1)
608-
src.coil[0].name = "CS3U"
609-
src.coil[0].identifier = "COIL_ID"
610-
611-
dst = convert_ids(src, "4.0.0")
612-
613-
# DD3 identifier -> DD4 name
614-
assert dst.coil[0].name == "COIL_ID"
615-
# DD3 name -> DD4 description
616-
assert dst.coil[0].description == "CS3U"
597+
assert dst.coil[1].name == "TEST_NAME2"
598+
assert dst.coil[1].description == "TEST_NAME2"
617599

618600

619601
def test_3to4_cocos_hardcoded_paths():

0 commit comments

Comments
 (0)