Skip to content

Commit d35d541

Browse files
committed
Add unitest
1 parent f3caf79 commit d35d541

1 file changed

Lines changed: 37 additions & 0 deletions

File tree

tests/driver_test.py

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,3 +57,40 @@ def test_smallness_terms(tmp_path: Path):
5757
params.alpha_s = None
5858
driver = GravityInversionDriver(params)
5959
assert driver.regularization.objfcts[0].alpha_s == 0.0
60+
61+
62+
def test_target_chi(tmp_path: Path, caplog):
63+
n_grid_points = 2
64+
refinement = (2,)
65+
66+
geoh5, _, model, survey, topography = setup_inversion_workspace(
67+
tmp_path,
68+
background=0.0,
69+
anomaly=0.75,
70+
n_electrodes=n_grid_points,
71+
n_lines=n_grid_points,
72+
refinement=refinement,
73+
flatten=False,
74+
)
75+
76+
with geoh5.open():
77+
gz = survey.add_data({"gz": {"values": np.ones(survey.n_vertices)}})
78+
mesh = model.parent
79+
active_cells = ActiveCellsOptions(topography_object=topography)
80+
params = GravityInversionOptions(
81+
geoh5=geoh5,
82+
mesh=mesh,
83+
active_cells=active_cells,
84+
data_object=gz.parent,
85+
gz_channel=gz,
86+
gz_uncertainty=2e-3,
87+
starting_model=1e-4,
88+
starting_chi_factor=1.0,
89+
chi_factor=2.0,
90+
)
91+
driver = GravityInversionDriver(params)
92+
93+
with caplog.at_level("WARNING"):
94+
assert driver.directives.update_irls_directive.chifact_start == 2.0
95+
96+
assert "Starting chi factor is greater" in caplog.text

0 commit comments

Comments
 (0)