@@ -456,6 +456,8 @@ def _apply_3to4_conversion(self, old: Element, new: Element) -> None:
456456 # Map DD3 name -> DD4 description
457457 if name_path not in self .old_to_new .path :
458458 self ._add_rename (name_path , desc_path )
459+ # GH#114: Also preserve name in DD4 name when identifier is empty
460+ self .old_to_new .type_change [name_path ] = _name_identifier_3to4
459461
460462 # Map DD3 identifier -> DD4 name
461463 if id_path in self .old_to_new .path :
@@ -1154,6 +1156,19 @@ def _circuit_connections_4to3(node: IDSPrimitive) -> None:
11541156 node .value = new_value
11551157
11561158
1159+ def _name_identifier_3to4 (source_name : IDSBase , target_description : IDSBase ) -> None :
1160+ """Preserve name when identifier is empty, see GH#114."""
1161+ # Always copy DD3 name -> DD4 description
1162+ target_description .value = source_name .value
1163+
1164+ # When DD3 identifier is empty, also preserve name in DD4 name
1165+ source_parent = source_name ._parent
1166+ source_identifier = getattr (source_parent , "identifier" , None )
1167+ if source_identifier is None or not source_identifier .value :
1168+ target_parent = target_description ._parent
1169+ target_parent .name = source_name .value
1170+
1171+
11571172def _ids_properties_source (source : IDSString0D , provenance : IDSStructure ) -> None :
11581173 """Handle DD3to4 migration of ids_properties/source to ids_properties/provenance."""
11591174 if len (provenance .node ) > 0 :
0 commit comments