[OASIS] repeated property keys should be merged, not overwritten
This commit is contained in:
parent
462a05a665
commit
08421d6a54
2 changed files with 20 additions and 1 deletions
|
|
@ -714,7 +714,7 @@ def properties_to_annotations(
|
||||||
string = repr(value)
|
string = repr(value)
|
||||||
logger.warning(f'Converting property value for key ({key}) to string ({string})')
|
logger.warning(f'Converting property value for key ({key}) to string ({string})')
|
||||||
values.append(string)
|
values.append(string)
|
||||||
annotations[key] = values
|
annotations.setdefault(key, []).extend(values)
|
||||||
return annotations
|
return annotations
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -4,6 +4,8 @@ from numpy.testing import assert_equal
|
||||||
|
|
||||||
from ..pattern import Pattern
|
from ..pattern import Pattern
|
||||||
from ..library import Library
|
from ..library import Library
|
||||||
|
|
||||||
|
|
||||||
def test_oasis_roundtrip(tmp_path: Path) -> None:
|
def test_oasis_roundtrip(tmp_path: Path) -> None:
|
||||||
# Skip if fatamorgana is not installed
|
# Skip if fatamorgana is not installed
|
||||||
pytest.importorskip("fatamorgana")
|
pytest.importorskip("fatamorgana")
|
||||||
|
|
@ -23,3 +25,20 @@ def test_oasis_roundtrip(tmp_path: Path) -> None:
|
||||||
|
|
||||||
# Check bounds
|
# Check bounds
|
||||||
assert_equal(read_lib["cell1"].get_bounds(), [[0, 0], [10, 10]])
|
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]}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue