Skip to content

Commit c4c7613

Browse files
committed
Merge branch 'main' of https://github.com/cgre-aachen/gempy
2 parents cd171fe + 9866d78 commit c4c7613

File tree

2 files changed

+20
-3
lines changed

2 files changed

+20
-3
lines changed

gempy/core/data_modules/geometric_data.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -162,7 +162,7 @@ def map_data_from_surfaces(self, surfaces, attribute: str, idx=None):
162162
def _add_surface_to_list_from_new_surface_points_or_orientations(self, idx, surface: list | str):
163163
if type(surface) is str: surface = [surface]
164164

165-
# Check is self.df['surface'] is a category
165+
# Check if self.df['surface'] is a category
166166
if not isinstance(self.df['surface'].dtype, pd.CategoricalDtype):
167167
self.df['surface'] = self.df['surface'].astype('category', copy=True)
168168
self.df['surface'] = self.df['surface'].cat.set_categories(self.surfaces.df['surface'].values)
@@ -172,7 +172,7 @@ def _add_surface_to_list_from_new_surface_points_or_orientations(self, idx, surf
172172
# if s not in self.df['surface'].cat.categories:
173173
# self.df['surface'] = self.df['surface'].cat.add_categories(s)
174174

175-
if type(idx) is int:
175+
if isinstance(idx, (np.int64, int)):
176176
self.df.loc[idx, 'surface'] = surface[0]
177177
elif type(idx) is list:
178178
self.df.loc[idx, 'surface'] = surface

test/test_core/test_data_mutation.py

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,7 @@
66
import numpy as np
77
import pytest
88
import os
9+
import matplotlib.pyplot as plt
910

1011
mm = gp.ImplicitCoKriging()
1112
mm.add_surfaces(['surface1', 'foo1', 'foo2', 'foo3'])
@@ -93,4 +94,20 @@ def test_read_data():
9394
model.read_data(path_i=data_path + "/data/input_data/tut_chapter1/simple_fault_model_points.csv",
9495
path_o=data_path + "/data/input_data/tut_chapter1/simple_fault_model_orientations.csv")
9596

96-
assert model._surface_points.df.shape[0] == 57
97+
assert model._surface_points.df.shape[0] == 57
98+
99+
def test_add_surface_points_to_model():
100+
geo_model = gp.create_model('TestModel1')
101+
gp.init_data(geo_model, extent=[0, 800, 0, 200, -600, 0], resolution=[100, 100, 100])
102+
geo_model.set_default_surfaces()
103+
104+
geo_model.add_surface_points(X=223, Y=0.01, Z=-94, surface='surface1')
105+
geo_model.add_surface_points(X=458, Y=0, Z=-107, surface='surface1')
106+
geo_model.add_surface_points(X=612, Y=0, Z=-14, surface='surface1')
107+
geo_model.add_orientations(X=350, Y=0, Z=-300, surface='surface1', pole_vector=(0, 0, 1))
108+
109+
geo_model.add_surface_points(X=225, Y=1, Z=-269, surface='surface2')
110+
geo_model.add_surface_points(X=459, Y=1, Z=-279, surface='surface2')
111+
112+
#gp.plot_2d(geo_model, cell_number=5, legend='force')
113+
#plt.show()

0 commit comments

Comments
 (0)