Skip to content

Commit 61b5af5

Browse files
authored
[CLN] Replace outputs_centers with outputs in octree access patterns (#1090)
# Description This change refactors the octree output data structure by renaming the `outputs_centers` attribute to `outputs` throughout the codebase. The change affects multiple modules including compatibility layers, engine factory, mesh extraction, and test files. Additionally, the debug flag is set to `false` in several test verification files, and a torch availability check is added to the nugget effect optimization test
2 parents 947a778 + 7a2544c commit 61b5af5

12 files changed

Lines changed: 23 additions & 19 deletions

File tree

gempy/API/gp2_gp3_compatibility/gp3_to_gp2_output.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -55,7 +55,7 @@ def _set_surfaces_meshes(geo_model: Project, meshes: list[DualContouringMesh]) -
5555
def _set_block_matrix(geo_model: Project, octree_output: OctreeLevel) -> Project:
5656
temp_list = []
5757
for i in range(octree_output.number_of_outputs):
58-
temp_list.append(octree_output.outputs_centers[i].values_block)
58+
temp_list.append(octree_output.outputs[i].values_block)
5959

6060
block_matrix_stacked = np.vstack(temp_list)
6161
geo_model.solutions.block_matrix = block_matrix_stacked
@@ -65,7 +65,7 @@ def _set_block_matrix(geo_model: Project, octree_output: OctreeLevel) -> Project
6565
def _set_scalar_field(geo_model: Project, octree_output: OctreeLevel) -> Project:
6666
temp_list = []
6767
for i in range(octree_output.number_of_outputs):
68-
temp_list.append(octree_output.outputs_centers[i].scalar_fields.exported_fields.scalar_field)
68+
temp_list.append(octree_output.outputs[i].scalar_fields.exported_fields.scalar_field)
6969

7070
scalar_field_stacked = np.vstack(temp_list)
7171
geo_model.solutions.scalar_field_matrix = scalar_field_stacked
@@ -75,7 +75,7 @@ def _set_scalar_field(geo_model: Project, octree_output: OctreeLevel) -> Project
7575
def _set_scalar_field_at_surface_points(geo_model: Project, octree_output: OctreeLevel) -> Project:
7676
temp_list = []
7777
for i in range(octree_output.number_of_outputs):
78-
temp_list.append(octree_output.outputs_centers[i].scalar_fields.exported_fields.scalar_field_at_surface_points)
78+
temp_list.append(octree_output.outputs[i].scalar_fields.exported_fields.scalar_field_at_surface_points)
7979

8080
geo_model.solutions.scalar_field_at_surface_points = temp_list
8181
return geo_model

gempy/modules/data_manipulation/_engine_factory.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -44,7 +44,7 @@ def interpolation_input_from_structural_frame(geo_model: "gempy.data.GeoModel")
4444

4545
weights = []
4646
if geo_model.solutions is not None:
47-
for stack_sol in geo_model.solutions.root_output.outputs_centers:
47+
for stack_sol in geo_model.solutions.root_output.outputs:
4848
weights.append(stack_sol.weights)
4949

5050
interpolation_input: InterpolationInput = InterpolationInput(

gempy/modules/mesh_extranction/marching_cubes.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,10 +30,10 @@ def set_meshes_with_marching_cubes(model: GeoModel) -> None:
3030
regular_grid: RegularGrid = model.grid.regular_grid
3131
structural_groups: list[StructuralGroup] = model.structural_frame.structural_groups
3232

33-
if not model.solutions.octrees_output or not model.solutions.octrees_output[0].outputs_centers:
33+
if not model.solutions.octrees_output or not model.solutions.octrees_output[0].outputs:
3434
raise ValueError("No interpolation outputs available for mesh extraction.")
3535

36-
output_lvl0: list[InterpOutput] = model.solutions.octrees_output[0].outputs_centers
36+
output_lvl0: list[InterpOutput] = model.solutions.octrees_output[0].outputs
3737

3838
for e, structural_group in enumerate(structural_groups):
3939
if e >= len(output_lvl0):

test/test_model_types/test_example_models_I.py

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

2323

2424
def _verify_scalar_field(model, name):
25-
outputs_centers_: InterpOutput = model.solutions.octrees_output[-1].outputs_centers[0]
25+
outputs_centers_: InterpOutput = model.solutions.octrees_output[-1].outputs[0]
2626
scalar_field = outputs_centers_.exported_fields.scalar_field
2727
scalar_field = scalar_field[::int(len(scalar_field) / 50)] # Pick 50 values from the scalar field array
2828
gempy_verify_array(scalar_field, name)

test/test_modules/test_cg/test_cg_solver.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -45,9 +45,9 @@ def test_save_weights():
4545
dtype='float32'
4646
)
4747
)
48-
weights1 = sol.octrees_output[0].outputs_centers[0].weights
49-
weights2 = sol.octrees_output[0].outputs_centers[1].weights
50-
weights3 = sol.octrees_output[0].outputs_centers[2].weights
48+
weights1 = sol.octrees_output[0].outputs[0].weights
49+
weights2 = sol.octrees_output[0].outputs[1].weights
50+
weights3 = sol.octrees_output[0].outputs[2].weights
5151

5252
WeightCache.clear_cache()
5353
BackendTensor.PYKEOPS = False

test/test_modules/test_faults/test_finite_faults.test_finite_fault_scalar_field_on_fault.verify/fault.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -220,7 +220,7 @@
220220
"compute_scalar_gradient": false,
221221
"verbose": false
222222
},
223-
"debug": true,
223+
"debug": false,
224224
"cache_mode": 3,
225225
"cache_model_name": "fault",
226226
"block_solutions_type": 1,

test/test_modules/test_geophysics/test_gravity.test_gravity.verify/2-layers.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -174,7 +174,7 @@
174174
"compute_scalar_gradient": false,
175175
"verbose": false
176176
},
177-
"debug": true,
177+
"debug": false,
178178
"cache_mode": 3,
179179
"cache_model_name": "2-layers",
180180
"block_solutions_type": 2,

test/test_modules/test_grids/test_custom_grid.test_custom_grid.verify/fold.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,7 @@
152152
"compute_scalar_gradient": false,
153153
"verbose": false
154154
},
155-
"debug": true,
155+
"debug": false,
156156
"cache_mode": 3,
157157
"cache_model_name": "fold",
158158
"block_solutions_type": 1,

test/test_modules/test_grids/test_grids_sections.test_section_grids.verify/fold.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"compute_scalar_gradient": false,
220220
"verbose": false
221221
},
222-
"debug": true,
222+
"debug": false,
223223
"cache_mode": 3,
224224
"cache_model_name": "fold",
225225
"block_solutions_type": 1,

test/test_modules/test_grids/test_grids_sections.test_topography_II.verify/Model1.approved.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -219,7 +219,7 @@
219219
"compute_scalar_gradient": false,
220220
"verbose": false
221221
},
222-
"debug": true,
222+
"debug": false,
223223
"cache_mode": 3,
224224
"cache_model_name": "Model1",
225225
"block_solutions_type": 2,

0 commit comments

Comments
 (0)