From 1fed08b17f571ec402e9bbe00891339b14a74bc2 Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Fri, 29 Aug 2025 17:15:36 -0400 Subject: [PATCH 1/3] Add underscore --- src/allotropy/allotrope/converter.py | 1 + 1 file changed, 1 insertion(+) diff --git a/src/allotropy/allotrope/converter.py b/src/allotropy/allotrope/converter.py index 34c4642cc..29548d1bb 100644 --- a/src/allotropy/allotrope/converter.py +++ b/src/allotropy/allotrope/converter.py @@ -106,6 +106,7 @@ "^": "_CARET_", "=": "_EQUALS_", "@": "_AT_", + "_": "_UNDERSCORE_", # NOTE: this MUST be at the end, or it will break other key replacements. " ": "_", } From 5da0d3ed345edf88859f1a75229e39872bf0e486 Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Fri, 29 Aug 2025 17:21:20 -0400 Subject: [PATCH 2/3] Actually this --- src/allotropy/allotrope/converter.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/allotropy/allotrope/converter.py b/src/allotropy/allotrope/converter.py index 29548d1bb..b4a463001 100644 --- a/src/allotropy/allotrope/converter.py +++ b/src/allotropy/allotrope/converter.py @@ -106,7 +106,7 @@ "^": "_CARET_", "=": "_EQUALS_", "@": "_AT_", - "_": "_UNDERSCORE_", + "'": "_QUOTE_", # NOTE: this MUST be at the end, or it will break other key replacements. " ": "_", } From 03df24a4ab90ec630d297f874990c25dbdb0d4b9 Mon Sep 17 00:00:00 2001 From: Nathan Stender Date: Fri, 29 Aug 2025 17:25:42 -0400 Subject: [PATCH 3/3] Test all the wierd keys --- tests/allotrope/converter_test.py | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/allotrope/converter_test.py b/tests/allotrope/converter_test.py index 05a7d0deb..7455effdd 100644 --- a/tests/allotrope/converter_test.py +++ b/tests/allotrope/converter_test.py @@ -135,11 +135,11 @@ def test_custom_information_document() -> None: cycle_threshold_value_setting=TQuantityValueUnitless(value=1.0), ), ), - {"extra key": "Value", "weird-key/(value)°": "Other value"}, + {"extra key": "Value", "$w.e\\ir:[d]-k'e~y/(v^a=l@ue)°#": "Other value"}, ) assert item.custom_information_document.extra_key == "Value" # type: ignore - assert item.custom_information_document.weird_DASH_key_SLASH__OPAREN_value_CPAREN__DEG_ == "Other value" # type: ignore + assert item.custom_information_document._DOLLAR_w_POINT_e_BSLASH_ir_COLON__OBRACKET_d_CBRACKET__DASH_k_QUOTE_e_TILDE_y_SLASH__OPAREN_v_CARET_a_EQUALS_l_AT_ue_CPAREN__DEG__NUMBER_ == "Other value" # type: ignore asm_dict = unstructure(item) assert asm_dict == { "cycle threshold result": {"value": None, "unit": "(unitless)"}, @@ -148,7 +148,7 @@ def test_custom_information_document() -> None: }, "custom information document": { "extra key": "Value", - "weird-key/(value)°": "Other value", + "$w.e\\ir:[d]-k'e~y/(v^a=l@ue)°#": "Other value", }, } assert structure(asm_dict, ProcessedDataDocumentItem) == item