Skip to content

Commit a64bbf0

Browse files
committed
[BUG] Handle potential ValueError in scalar field computation and enforce proper cache initialization in tests and fixtures
1 parent c78033e commit a64bbf0

File tree

4 files changed

+16
-2
lines changed

4 files changed

+16
-2
lines changed

gempy_engine/modules/evaluator/generic_evaluator.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,10 @@ def _eval_on(
7272
eval_kernel = yield_evaluation_kernel(
7373
solver_input, options.kernel_options, slice_array=slice_array
7474
)
75-
scalar_field = (eval_kernel.T @ weights).reshape(-1)
75+
try:
76+
scalar_field = (eval_kernel.T @ weights).reshape(-1)
77+
except ValueError:
78+
pass
7679

7780
gx_field: Optional[np.ndarray] = None
7881
gy_field: Optional[np.ndarray] = None

tests/fixtures/simple_geometries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ def unconformity() -> Tuple[InterpolationInput, InterpolationOptions, InputDataD
4949
options = InterpolationOptions.from_args(range_, c_o, uni_degree=1, i_res=i_r, gi_res=gi_r,
5050
number_dimensions=3,
5151
kernel_function=AvailableKernelFunctions.cubic)
52-
52+
options.cache_mode = InterpolationOptions.CacheMode.NO_CACHE
5353
resolution = [2, 2, 2]
5454
extent = [0, 1000, 0, 1000, 0, 1000]
5555

tests/fixtures/simple_models.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -169,6 +169,7 @@ def simple_model_interpolation_input_factory():
169169
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
170170
interpolation_options = InterpolationOptions.from_args(range_, co, 0, number_dimensions=3,
171171
kernel_function=AvailableKernelFunctions.cubic)
172+
interpolation_options.cache_mode = InterpolationOptions.CacheMode.NO_CACHE
172173
ids = np.array([1, 2])
173174
interpolation_input = InterpolationInput(spi, ori_i, grid_0_centers, ids)
174175
tensor_struct = TensorsStructure(np.array([7]))
@@ -279,6 +280,7 @@ def simple_model_3_layers_high_res(simple_grid_3d_more_points_grid) -> Tuple[Int
279280

280281
interpolation_options = InterpolationOptions.from_args(range_, co, 0,
281282
number_dimensions=3, kernel_function=AvailableKernelFunctions.cubic)
283+
interpolation_options.cache_mode = InterpolationOptions.CacheMode.NO_CACHE
282284

283285
ids = np.array([1, 2, 3, 4])
284286

tests/test_common/test_integrations/test_interpolate_model.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,9 @@
1212

1313

1414
def test_interpolate_model(simple_model_interpolation_input, n_oct_levels=3):
15+
16+
from gempy_engine.modules.weights_cache.weights_cache_interface import WeightCache
17+
WeightCache.initialize_cache_dir()
1518
"""Kernel function Cubic"""
1619
interpolation_input, options, structure = simple_model_interpolation_input
1720
print(interpolation_input)
@@ -29,6 +32,9 @@ def test_interpolate_model(simple_model_interpolation_input, n_oct_levels=3):
2932

3033
@pytest.mark.skipif(TEST_SPEED.value <= 1, reason="Global test speed below this test value.")
3134
def test_interpolate_model_no_octtree(simple_model_3_layers_high_res, n_oct_levels=2):
35+
36+
from gempy_engine.modules.weights_cache.weights_cache_interface import WeightCache
37+
WeightCache.initialize_cache_dir()
3238
interpolation_input, options, structure = simple_model_3_layers_high_res
3339
print(interpolation_input)
3440

@@ -44,6 +50,9 @@ def test_interpolate_model_no_octtree(simple_model_3_layers_high_res, n_oct_leve
4450

4551

4652
def test_interpolate_model_several_surfaces(simple_model_3_layers, n_oct_levels=3):
53+
54+
from gempy_engine.modules.weights_cache.weights_cache_interface import WeightCache
55+
WeightCache.initialize_cache_dir()
4756
interpolation_input, options, structure = simple_model_3_layers
4857
print(interpolation_input)
4958

0 commit comments

Comments
 (0)