diff --git a/masque/file/oasis.py b/masque/file/oasis.py index 5e343ea..95a2039 100644 --- a/masque/file/oasis.py +++ b/masque/file/oasis.py @@ -714,7 +714,7 @@ def properties_to_annotations( string = repr(value) logger.warning(f'Converting property value for key ({key}) to string ({string})') values.append(string) - annotations[key] = values + annotations.setdefault(key, []).extend(values) return annotations diff --git a/masque/test/test_oasis.py b/masque/test/test_oasis.py index b1129f4..ad9bbf9 100644 --- a/masque/test/test_oasis.py +++ b/masque/test/test_oasis.py @@ -4,6 +4,8 @@ from numpy.testing import assert_equal from ..pattern import Pattern from ..library import Library + + def test_oasis_roundtrip(tmp_path: Path) -> None: # Skip if fatamorgana is not installed pytest.importorskip("fatamorgana") @@ -23,3 +25,20 @@ def test_oasis_roundtrip(tmp_path: Path) -> None: # Check bounds assert_equal(read_lib["cell1"].get_bounds(), [[0, 0], [10, 10]]) + + +def test_oasis_properties_to_annotations_merges_repeated_keys() -> None: + pytest.importorskip("fatamorgana") + import fatamorgana.records as fatrec + from ..file.oasis import properties_to_annotations + + annotations = properties_to_annotations( + [ + fatrec.Property("k", [1], is_standard=False), + fatrec.Property("k", [2, 3], is_standard=False), + ], + {}, + {}, + ) + + assert annotations == {"k": [1, 2, 3]}