Skip to content

Commit

Permalink
Reset input file on geoh5 change. Augment tests
Browse files Browse the repository at this point in the history
  • Loading branch information
domfournier committed Feb 21, 2024
1 parent 1363ed0 commit d83e0d8
Show file tree
Hide file tree
Showing 2 changed files with 47 additions and 0 deletions.
8 changes: 8 additions & 0 deletions geoapps/driver_base/params.py
Original file line number Diff line number Diff line change
Expand Up @@ -280,6 +280,14 @@ def geoh5(self, val):
if val is None:
self._geoh5 = val
return

if self.input_file is not None and self.input_file.geoh5 is not None:
self.input_file = InputFile(
ui_json=self._default_ui_json,
validations=self.validations,
validate=False,
)

self.setter_validator(
"geoh5",
val,
Expand Down
39 changes: 39 additions & 0 deletions tests/run_tests/octree_creation_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -398,3 +398,42 @@ def test_octree_diagonal_balance(

assert (values == np.array(exp_values)).all()
assert (counts == np.array(exp_counts)).all()


def test_app_change_geoh5(tmp_path: Path, setup_test_octree):
(
cell_sizes,
depth_core,
horizontal_padding,
locations,
minimum_level,
refinement,
_,
vertical_padding,
) = setup_test_octree

with Workspace.create(tmp_path / "testOctree.geoh5") as workspace:
points = Points.create(workspace, vertices=locations)
refinements = {
"Refinement A object": points.uid,
"Refinement A levels": refinement,
"Refinement A type": "surface",
"Refinement B object": None,
"minimum_level": minimum_level,
}
app = OctreeMesh(
geoh5=workspace,
objects=str(points.uid),
u_cell_size=cell_sizes[0],
v_cell_size=cell_sizes[1],
w_cell_size=cell_sizes[2],
horizontal_padding=horizontal_padding,
vertical_padding=vertical_padding,
diagonal_balance=False,
depth_core=depth_core,
**refinements,
)
new_workspace = Workspace.create(tmp_path / "testOctree_new.geoh5")
new_workspace.close()

app.h5file = new_workspace.h5file

0 comments on commit d83e0d8

Please sign in to comment.