Skip to content

Commit bf735bb

Browse files
authored
Merge pull request #295 from MiraGeoscience/GEOPY-2549B
GEOPY-2549: Random failure of sensitvity cutoff app tests
2 parents 0659d66 + cdffc39 commit bf735bb

2 files changed

Lines changed: 10 additions & 4 deletions

File tree

simpeg_drivers/depth_of_investigation/sensitivity_cutoff/driver.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def lower_percent_mask(data: np.ndarray, cutoff: float, logspace=False) -> np.nd
6464
if logspace:
6565
data[data == 0] = np.nan
6666
data = np.log10(data)
67-
data -= np.nanmin(data)
6867

68+
data -= np.nanmin(data)
6969
scaled_data = data * 100 / np.nanmax(data)
7070
mask = scaled_data > cutoff
7171

tests/run_tests/sensitivity_cutoff_test.py

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,12 @@ def setup_inversion_results(
5555
{"gz": {"values": np.random.randn(len(components.survey.vertices))}}
5656
)
5757

58+
# Shift some vertices to avoid 0 sensititives
59+
verts = components.survey.vertices
60+
verts[:, 2] += np.arange(len(verts))
61+
62+
components.survey.vertices = verts
63+
5864
params = GravityInversionOptions.build(
5965
geoh5=geoh5,
6066
mesh=components.mesh,
@@ -110,7 +116,7 @@ def test_sensitivity_percent_cutoff_run(tmp_path):
110116
SensitivityCutoffDriver.start(str(tmp_path / "sensitivity_cutoff_percent.ui.json"))
111117
with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5:
112118
mask = geoh5.get_entity("5 percent cutoff")[0]
113-
assert mask.values.sum() == 1355
119+
assert mask.values.sum() == 2546
114120

115121

116122
def test_sensitivity_cutoff_percentile_run(tmp_path):
@@ -138,7 +144,7 @@ def test_sensitivity_cutoff_percentile_run(tmp_path):
138144
)
139145
with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5:
140146
mask = geoh5.get_entity("5 percentile cutoff")[0]
141-
assert mask.values.sum() == 22861
147+
assert mask.values.sum() == 22962
142148

143149

144150
def test_sensitivity_cutoff_log_percent_run(tmp_path):
@@ -166,4 +172,4 @@ def test_sensitivity_cutoff_log_percent_run(tmp_path):
166172
)
167173
with Workspace(tmp_path / "inversion_test.ui.geoh5") as geoh5:
168174
mask = geoh5.get_entity("5 percent log cutoff")[0]
169-
assert mask.values.sum() == 23144
175+
assert mask.values.sum() == 23178

0 commit comments

Comments
 (0)