Skip to content

Commit ba7c0c8

Browse files
committed
handle naming changes in ui.json files with aliases
1 parent 0b5b55e commit ba7c0c8

2 files changed

Lines changed: 8 additions & 3 deletions

File tree

simpeg_drivers/plate_simulation/models/options.py

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
from pydantic import (
1717
BaseModel,
1818
ConfigDict,
19+
Field,
1920
ValidationInfo,
2021
field_validator,
2122
model_validator,
@@ -46,7 +47,7 @@ class PlateOptions(BaseModel):
4647
model_config = ConfigDict(arbitrary_types_allowed=True)
4748

4849
name: str = "Plate"
49-
plate_property: float
50+
plate_property: float = Field(validation_alias="plate")
5051
geometry: PlateModel
5152
number: int = 1
5253
spacing: float = 0.0
@@ -124,7 +125,7 @@ class OverburdenOptions(BaseModel):
124125
"""
125126

126127
thickness: float
127-
overburden_property: float
128+
overburden_property: float = Field(validation_alias="overburden")
128129

129130

130131
class ModelOptions(BaseModel):

tests/plate_simulation/runtest/gravity_test.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,11 @@ def test_gravity_plate_simulation(tmp_path):
5555
plate_refinement=[4, 2],
5656
)
5757

58-
overburden_params = OverburdenOptions(thickness=50.0, overburden_property=0.2)
58+
overburden_params = OverburdenOptions(
59+
thickness=50.0,
60+
overburden=0.2, # tests alias handling
61+
)
62+
assert overburden_params.overburden_property == 0.2
5963

6064
plate_params = PlateOptions(
6165
name="plate",

0 commit comments

Comments
 (0)