Skip to content

Commit 6160b7f

Browse files
committed
remove aliasing as it breaks tests since collect_from_dict recurses and finds 'plate' and 'overbuden' fields elsewhere in the model.
1 parent 44af353 commit 6160b7f

4 files changed

Lines changed: 13 additions & 12 deletions

File tree

simpeg_drivers/plate_simulation/models/options.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -47,7 +47,7 @@ class PlateOptions(BaseModel):
4747
model_config = ConfigDict(arbitrary_types_allowed=True)
4848

4949
name: str = "Plate"
50-
plate_property: float = Field(validation_alias="plate")
50+
plate_property: float
5151
geometry: PlateModel
5252
number: int = 1
5353
spacing: float = 0.0
@@ -125,7 +125,7 @@ class OverburdenOptions(BaseModel):
125125
"""
126126

127127
thickness: float
128-
overburden_property: float = Field(validation_alias="overburden")
128+
overburden_property: float
129129

130130

131131
class ModelOptions(BaseModel):

simpeg_drivers/utils/synthetics/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -80,7 +80,7 @@ def plate(self) -> Surface | None:
8080
@property
8181
def mesh(self) -> Octree | DrapeModel:
8282
if self._mesh is None:
83-
entity = self.geoh5.get_entity("mesh")[0]
83+
entity = self.geoh5.get_entity(self.options.mesh.name)[0]
8484
if entity is None:
8585
entity = get_mesh(
8686
self.options.method,

simpeg_drivers/utils/synthetics/options.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,8 @@
1313
import numpy as np
1414
from geoapps_utils.modelling.plates import PlateModel
1515
from geoapps_utils.utils.locations import gaussian
16-
from geoh5py.objects import ObjectBase, Surface
16+
from geoh5py.objects import ObjectBase, Points, Surface
17+
from geoh5py.shared.utils import fetch_active_workspace
1718
from grid_apps.octree_creation.options import OctreeOptions
1819
from pydantic import BaseModel, ConfigDict
1920

@@ -77,16 +78,20 @@ def octree_params(
7778
7879
:return: OctreeOptions instance ready to be passed to an OctreeDriver.
7980
"""
80-
shifted_survey = survey.copy()
81-
shifted_survey.vertices = shifted_survey.vertices - np.r_[self.cell_size] / 2.0
81+
82+
locs = survey.vertices.copy()
83+
locs = np.vstack([locs, locs - np.r_[self.cell_size] / 2])
84+
with fetch_active_workspace(survey.workspace) as geoh5:
85+
survey = Points.create(geoh5, vertices=locs)
86+
8287
refinements = [
8388
{
8489
"refinement_object": survey,
8590
"levels": self.survey_refinement,
8691
"horizon": False,
8792
},
8893
{
89-
"refinement_object": shifted_survey,
94+
"refinement_object": survey,
9095
"levels": self.survey_refinement,
9196
"horizon": False,
9297
},

tests/plate_simulation/runtest/gravity_test.py

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

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

6460
plate_params = PlateOptions(
6561
name="plate",

0 commit comments

Comments
 (0)