Skip to content

Commit c78b7a0

Browse files
committed
[ENH] Refactor to use InterpolationOptions.from_args
Replaced direct instantiation of `InterpolationOptions` with the `from_args` class method across multiple modules and tests for consistency and improved clarity. Updated related examples and fixtures to align with this change.
1 parent d7c0d57 commit c78b7a0

File tree

13 files changed

+29
-26
lines changed

13 files changed

+29
-26
lines changed

gempy_engine/API/server/main_server_pro.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@
2727

2828
# Default interpolation options
2929
range_ = 1
30-
default_interpolation_options: InterpolationOptions = InterpolationOptions(
30+
default_interpolation_options: InterpolationOptions = InterpolationOptions.from_args(
3131
range=range_,
3232
c_o=(range_ ** 2) / 14 / 3,
3333
number_octree_levels=4,

gempy_engine/core/data/options/interpolation_options.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -43,6 +43,9 @@ class CacheMode(enum.Enum):
4343
default_factory=TempInterpolationValues,
4444
exclude=True
4545
)
46+
47+
def __init__(self):
48+
pass
4649

4750
# endregion
4851

@@ -90,7 +93,7 @@ def from_args(
9093
block_solutions_type = RawArraysSolution.BlockSolutionType.OCTREE
9194
sigmoid_slope = 5_000_000
9295

93-
return InterpolationOptions(
96+
return InterpolationOptions.from_args(
9497
kernel_options=kernel_options,
9598
evaluation_options=evaluation_options,
9699
# temp_interpolation_values=temp_interpolation_values,
@@ -106,7 +109,7 @@ def from_args(
106109

107110
@classmethod
108111
def init_octree_options(cls, range=1.7, c_o=10, refinement: int = 1):
109-
return InterpolationOptions(
112+
return InterpolationOptions.from_args(
110113
range=range,
111114
c_o=c_o,
112115
mesh_extraction=True,
@@ -115,7 +118,7 @@ def init_octree_options(cls, range=1.7, c_o=10, refinement: int = 1):
115118

116119
@classmethod
117120
def init_dense_grid_options(cls):
118-
options = InterpolationOptions(
121+
options = InterpolationOptions.from_args(
119122
range=1.7,
120123
c_o=10,
121124
mesh_extraction=False,
@@ -130,7 +133,7 @@ def probabilistic_options(cls):
130133
raise NotImplementedError("Probabilistic interpolation is not yet implemented.")
131134

132135
# def __repr__(self):
133-
# return f"InterpolationOptions({', '.join(f'{k}={v}' for k, v in asdict(self).items())})"
136+
# return f"InterpolationOptions.from_args({', '.join(f'{k}={v}' for k, v in asdict(self).items())})"
134137

135138
# def _repr_html_(self):
136139
# html = f"""

gempy_engine/modules/kernel_constructor/_pykeops_cov_compiler.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ def simple_model_2():
4040
ori_i = Orientations(dip_positions, nugget_effect_grad)
4141

4242
range = 5 ** 2
43-
kri = InterpolationOptions(range, 1, 0, i_res=1, gi_res=1,
43+
kri = InterpolationOptions.from_args(range, 1, 0, i_res=1, gi_res=1,
4444
number_dimensions=2)
4545

4646
_ = np.ones(3)

tests/benchmark/one_fault_model.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ def one_fault_model():
9393
range_ = 7 ** 2 # ? Since we are not getting the square root should we also square this?
9494
c_o = 1
9595

96-
options = InterpolationOptions(
96+
options = InterpolationOptions.from_args(
9797
range_, c_o,
9898
uni_degree=1,
9999
number_dimensions=3,

tests/fixtures/complex_geometries.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,7 @@ def one_fault_model():
7777
range_ = 7 ** 2 # ? Since we are not getting the square root should we also square this?
7878
c_o = 1
7979

80-
options = InterpolationOptions(
80+
options = InterpolationOptions.from_args(
8181
range_, c_o,
8282
uni_degree=1,
8383
number_dimensions=3,
@@ -144,7 +144,7 @@ def one_finite_fault_model():
144144
range_ = 7 ** 2 # ? Since we are not getting the square root should we also square this?
145145
c_o = 1
146146

147-
options = InterpolationOptions(
147+
options = InterpolationOptions.from_args(
148148
range_, c_o,
149149
uni_degree=1,
150150
number_dimensions=3,
@@ -211,7 +211,7 @@ def graben_fault_model():
211211
range_ = 7 ** 2 # ? Since we are not getting the square root should we also square this?
212212
c_o = 1
213213

214-
options = InterpolationOptions(
214+
options = InterpolationOptions.from_args(
215215
range_, c_o,
216216
uni_degree=1,
217217
number_dimensions=3,

tests/fixtures/heavy_models.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def moureze_model_factory(path_to_root: str, pick_every=8, octree_lvls=3, solver
102102
# endregion
103103

104104
# region InterpolationOptions
105-
interpolation_options: InterpolationOptions = InterpolationOptions(
105+
interpolation_options: InterpolationOptions = InterpolationOptions.from_args(
106106
range=100.,
107107
c_o=10.,
108108
number_octree_levels=octree_lvls,

tests/fixtures/simple_geometries.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,7 @@ def unconformity() -> Tuple[InterpolationInput, InterpolationOptions, InputDataD
4646
i_r = 4
4747
gi_r = 2
4848

49-
options = InterpolationOptions(range_, c_o, uni_degree=1, i_res=i_r, gi_res=gi_r,
49+
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)
5252

tests/fixtures/simple_models.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ def simple_model_2_factory() -> Tuple[SurfacePoints, Orientations, Interpolation
5656
[0, .8]])
5757
nugget_effect_grad = 0.0000001
5858
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
59-
kri = InterpolationOptions(5, 5 ** 2 / 14 / 3, 0,
59+
kri = InterpolationOptions.from_args(5, 5 ** 2 / 14 / 3, 0,
6060
number_dimensions=2, kernel_function=AvailableKernelFunctions.cubic)
6161
tensor_struct = TensorsStructure(number_of_points_per_surface=np.array([4, 3]))
6262
stack_structure = StacksStructure(number_of_points_per_stack=np.array([7]),
@@ -113,7 +113,7 @@ def _gen():
113113
range_ = 4.166666666667
114114
co = 0.1428571429
115115
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
116-
kri = InterpolationOptions(
116+
kri = InterpolationOptions.from_args(
117117
range_,
118118
co,
119119
0,
@@ -163,7 +163,7 @@ def simple_model_interpolation_input_factory():
163163
range_ = 4.166666666667
164164
co = 0.1428571429
165165
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
166-
interpolation_options = InterpolationOptions(range_, co, 0, number_dimensions=3,
166+
interpolation_options = InterpolationOptions.from_args(range_, co, 0, number_dimensions=3,
167167
kernel_function=AvailableKernelFunctions.cubic)
168168
ids = np.array([1, 2])
169169
interpolation_input = InterpolationInput(spi, ori_i, grid_0_centers, ids)
@@ -217,7 +217,7 @@ def _gen_simple_model_3_layers(simple_grid_3d_octree):
217217
range_ = 4.166666666667
218218
co = 0.1428571429
219219
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
220-
interpolation_options = InterpolationOptions(range_, co, 0, i_res=4, gi_res=2,
220+
interpolation_options = InterpolationOptions.from_args(range_, co, 0, i_res=4, gi_res=2,
221221
number_dimensions=3, kernel_function=AvailableKernelFunctions.cubic)
222222
tensor_structure = TensorsStructure(number_of_points_per_surface=np.array([7, 2, 2]))
223223
stack_structure = StacksStructure(number_of_points_per_stack=np.array([11]),
@@ -267,7 +267,7 @@ def simple_model_3_layers_high_res(simple_grid_3d_more_points_grid) -> Tuple[Int
267267

268268
ori_i = Orientations(dip_positions, dip_gradients, nugget_effect_grad)
269269

270-
interpolation_options = InterpolationOptions(range_, co, 0,
270+
interpolation_options = InterpolationOptions.from_args(range_, co, 0,
271271
number_dimensions=3, kernel_function=AvailableKernelFunctions.cubic)
272272

273273
ids = np.array([1, 2, 3, 4])
@@ -386,7 +386,7 @@ def unconformity_complex_factory():
386386
c_o = 35.71428571 * 100
387387
i_r = 4
388388
gi_r = 2
389-
options = InterpolationOptions(
389+
options = InterpolationOptions.from_args(
390390
range_, c_o, uni_degree=0, i_res=i_r, gi_res=gi_r,
391391
number_dimensions=3,
392392
kernel_function=AvailableKernelFunctions.cubic)
@@ -439,7 +439,7 @@ def unconformity_complex_implicit():
439439
i_r = 4
440440
gi_r = 2
441441

442-
options = InterpolationOptions(range_, c_o, uni_degree=0, i_res=i_r, gi_res=gi_r,
442+
options = InterpolationOptions.from_args(range_, c_o, uni_degree=0, i_res=i_r, gi_res=gi_r,
443443
number_dimensions=3,
444444
kernel_function=AvailableKernelFunctions.cubic)
445445

@@ -477,7 +477,7 @@ def unconformity_complex_one_layer():
477477
i_r = 4
478478
gi_r = 2
479479

480-
options = InterpolationOptions(range_, c_o, uni_degree=0, i_res=i_r, gi_res=gi_r,
480+
options = InterpolationOptions.from_args(range_, c_o, uni_degree=0, i_res=i_r, gi_res=gi_r,
481481
number_dimensions=3,
482482
kernel_function=AvailableKernelFunctions.cubic)
483483

tests/test_common/test_api/test_public_interface.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ def test_public_interface_simplest_model():
6060

6161
# region InterpolationOptions
6262

63-
interpolation_options: InterpolationOptions = InterpolationOptions(
63+
interpolation_options: InterpolationOptions = InterpolationOptions.from_args(
6464
range=4.166666666667, # TODO: have constructor from RegularGrid
6565
c_o=0.1428571429, # TODO: This should be a property
6666
number_octree_levels=3,

tests/test_common/test_integrations/test_kernels.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77

88
def test_interpolate_model_cubic(n_oct_levels=3):
99
interpolation_input, options, structure = simple_model_interpolation_input_factory()
10-
options = InterpolationOptions(
10+
options = InterpolationOptions.from_args(
1111
range=options.range,
1212
c_o=options.c_o,
1313
uni_degree=0,
@@ -31,7 +31,7 @@ def test_interpolate_model_cubic(n_oct_levels=3):
3131
def test_interpolate_model_exponential(n_oct_levels=3):
3232
interpolation_input, options, structure = simple_model_interpolation_input_factory()
3333

34-
options = InterpolationOptions(
34+
options = InterpolationOptions.from_args(
3535
range=options.range,
3636
c_o=options.c_o,
3737
uni_degree=0,

0 commit comments

Comments
 (0)