2222import os
2323import sys
2424import platform
25+
2526if sys .version_info >= (3 , 8 , 0 ) and platform .system () == "Windows" :
26- for path in [x .strip () for x in os .environ [' PATH' ].split (';' ) if x ]:
27+ for path in [x .strip () for x in os .environ [" PATH" ].split (";" ) if x ]:
2728 os .add_dll_directory (path )
2829
2930import opengeode
3334def add_faults (model , builder ):
3435 fault0 = builder .add_fault ()
3536 if model .fault (fault0 ).has_type ():
36- raise ValueError (
37- "[Test] Addition of a Fault in StructuralModel is not correct" )
37+ raise ValueError ("[Test] Addition of a Fault in StructuralModel is not correct" )
3838
3939 fault1 = builder .add_fault ()
4040 builder .set_fault_name (fault1 , "fault1" )
4141 if model .nb_faults () != 2 :
42- raise ValueError (
43- "[Test] Number of faults in StructuralModel should be 2" )
42+ raise ValueError ("[Test] Number of faults in StructuralModel should be 2" )
4443 if model .fault (fault1 ).name () != "fault1" :
4544 raise ValueError ("[Test] Wrong Fault name" )
4645
@@ -54,16 +53,19 @@ def add_faults(model, builder):
5453
5554def add_horizons (model , builder ):
5655 horizon0 = builder .add_horizon ()
57- if model .horizon (horizon0 ).contact_type ()!= geosciences .Horizon3D .CONTACT_TYPE .CONFORMAL :
56+ if (
57+ model .horizon (horizon0 ).contact_type ()
58+ != geosciences .Horizon3D .CONTACT_TYPE .CONFORMAL
59+ ):
5860 raise ValueError (
59- "[Test] Addition of a Horizon in StructuralModel is not correct" )
61+ "[Test] Addition of a Horizon in StructuralModel is not correct"
62+ )
6063
6164 horizon1 = builder .add_horizon ()
6265 horizon2 = builder .add_horizon ()
6366 builder .set_horizon_name (horizon2 , "horizon2" )
6467 if model .nb_horizons () != 3 :
65- raise ValueError (
66- "[Test] Number of horizons in StructuralModel should be 3" )
68+ raise ValueError ("[Test] Number of horizons in StructuralModel should be 3" )
6769 if model .horizon (horizon2 ).name () != "horizon2" :
6870 raise ValueError ("[Test] Wrong Horizon name" )
6971
@@ -82,34 +84,34 @@ def add_surfaces(builder):
8284
8385def do_checks (model , surface_uuids , faults_uuids , horizons_uuids ):
8486 if model .nb_items (faults_uuids [0 ]) != 3 :
85- raise ValueError (
86- "[Test] Number of items in fault_uuids[0] should be 3" )
87+ raise ValueError ("[Test] Number of items in fault_uuids[0] should be 3" )
8788 if model .nb_items (faults_uuids [1 ]) != 2 :
88- raise ValueError (
89- "[Test] Number of items in fault_uuids[1] should be 2" )
89+ raise ValueError ("[Test] Number of items in fault_uuids[1] should be 2" )
9090
9191 if model .nb_items (horizons_uuids [0 ]) != 1 :
92- raise ValueError (
93- "[Test] Number of items in horizons_uuids[0] should be 1" )
92+ raise ValueError ("[Test] Number of items in horizons_uuids[0] should be 1" )
9493 if model .nb_items (horizons_uuids [1 ]) != 0 :
95- raise ValueError (
96- "[Test] Number of items in horizons_uuids[1] should be 0" )
94+ raise ValueError ("[Test] Number of items in horizons_uuids[1] should be 0" )
9795 if model .nb_items (horizons_uuids [2 ]) != 3 :
98- raise ValueError (
99- "[Test] Number of items in horizons_uuids[2] should be 3" )
96+ raise ValueError ("[Test] Number of items in horizons_uuids[2] should be 3" )
10097
10198 for i in range (8 ):
10299 if i != 2 :
103100 if model .nb_collections (surface_uuids [i ]) != 1 :
104101 raise ValueError (
105- "[Test] Number of collections in which surfaces_uuids[" , i , "] is should be 1" )
102+ "[Test] Number of collections in which surfaces_uuids[" ,
103+ i ,
104+ "] is should be 1" ,
105+ )
106106
107107 if len (model .horizon_items (model .horizon (horizons_uuids [2 ]))) != 3 :
108108 raise ValueError (
109- "[Test] Number of iterations on items in horizons_uuids[2] should be 3" )
109+ "[Test] Number of iterations on items in horizons_uuids[2] should be 3"
110+ )
110111 if len (model .fault_items (model .fault (faults_uuids [1 ]))) != 2 :
111112 raise ValueError (
112- "[Test] Number of iterations on items in faults_uuids[1] should be 2" )
113+ "[Test] Number of iterations on items in faults_uuids[1] should be 2"
114+ )
113115
114116
115117def build_relations_between_geometry_and_geology (model , builder ):
@@ -123,39 +125,45 @@ def build_relations_between_geometry_and_geology(model, builder):
123125 for horizon in model .horizons ():
124126 horizons_uuids .append (horizon .id ())
125127
126- builder .add_surface_in_fault (model .surface (
127- surfaces_uuids [0 ]), model .fault (faults_uuids [0 ]))
128- builder .add_surface_in_fault (model .surface (
129- surfaces_uuids [1 ]), model .fault (faults_uuids [0 ]))
130- builder .add_surface_in_fault (model .surface (
131- surfaces_uuids [2 ]), model .fault (faults_uuids [0 ]))
132- builder .add_surface_in_fault (model .surface (
133- surfaces_uuids [2 ]), model .fault (faults_uuids [1 ]))
134- builder .add_surface_in_fault (model .surface (
135- surfaces_uuids [3 ]), model .fault (faults_uuids [1 ]))
136-
137- builder .add_surface_in_horizon (model .surface (
138- surfaces_uuids [4 ]), model .horizon (horizons_uuids [0 ]))
139- builder .add_surface_in_horizon (model .surface (
140- surfaces_uuids [5 ]), model .horizon (horizons_uuids [2 ]))
141- builder .add_surface_in_horizon (model .surface (
142- surfaces_uuids [6 ]), model .horizon (horizons_uuids [2 ]))
143- builder .add_surface_in_horizon (model .surface (
144- surfaces_uuids [7 ]), model .horizon (horizons_uuids [2 ]))
128+ builder .add_surface_in_fault (
129+ model .surface (surfaces_uuids [0 ]), model .fault (faults_uuids [0 ])
130+ )
131+ builder .add_surface_in_fault (
132+ model .surface (surfaces_uuids [1 ]), model .fault (faults_uuids [0 ])
133+ )
134+ builder .add_surface_in_fault (
135+ model .surface (surfaces_uuids [2 ]), model .fault (faults_uuids [0 ])
136+ )
137+ builder .add_surface_in_fault (
138+ model .surface (surfaces_uuids [2 ]), model .fault (faults_uuids [1 ])
139+ )
140+ builder .add_surface_in_fault (
141+ model .surface (surfaces_uuids [3 ]), model .fault (faults_uuids [1 ])
142+ )
143+
144+ builder .add_surface_in_horizon (
145+ model .surface (surfaces_uuids [4 ]), model .horizon (horizons_uuids [0 ])
146+ )
147+ builder .add_surface_in_horizon (
148+ model .surface (surfaces_uuids [5 ]), model .horizon (horizons_uuids [2 ])
149+ )
150+ builder .add_surface_in_horizon (
151+ model .surface (surfaces_uuids [6 ]), model .horizon (horizons_uuids [2 ])
152+ )
153+ builder .add_surface_in_horizon (
154+ model .surface (surfaces_uuids [7 ]), model .horizon (horizons_uuids [2 ])
155+ )
145156
146157 do_checks (model , surfaces_uuids , faults_uuids , horizons_uuids )
147158
148159
149160def check_reloaded_model (reloaded_model ):
150161 if reloaded_model .nb_surfaces () != 8 :
151- raise ValueError (
152- "[Test] Number of surfaces in reloaded model should be 8" )
162+ raise ValueError ("[Test] Number of surfaces in reloaded model should be 8" )
153163 if reloaded_model .nb_horizons () != 3 :
154- raise ValueError (
155- "[Test] Number of horizons in reloaded model should be 3" )
164+ raise ValueError ("[Test] Number of horizons in reloaded model should be 3" )
156165 if reloaded_model .nb_faults () != 2 :
157- raise ValueError (
158- "[Test] Number of faults in reloaded model should be 2" )
166+ raise ValueError ("[Test] Number of faults in reloaded model should be 2" )
159167
160168
161169def test_io (model ):
@@ -171,18 +179,15 @@ def test_copy(model):
171179 copier .copy (model )
172180
173181 if copy .nb_surfaces () != 8 :
174- raise ValueError (
175- "[Test] Number of surfaces in copied model should be 8" )
182+ raise ValueError ("[Test] Number of surfaces in copied model should be 8" )
176183 if copy .nb_horizons () != 3 :
177- raise ValueError (
178- "[Test] Number of horizons in copied model should be 3" )
184+ raise ValueError ("[Test] Number of horizons in copied model should be 3" )
179185 if copy .nb_faults () != 2 :
180186 raise ValueError ("[Test] Number of faults in copied model should be 2" )
181187 if copy .nb_fault_blocks () != 0 :
182- raise ValueError (
183- "[Test] Number of fault blocks in copied model should be 0" )
188+ raise ValueError ("[Test] Number of fault blocks in copied model should be 0" )
184189
185- #nb_surface_boundaries = 0
190+ # nb_surface_boundaries = 0
186191 # for surface in copy.surfaces():
187192 # nb_surface_boundaries += len( copy.boundaries( surface ) )
188193 # if nb_surface_boundaries != 8:
@@ -192,44 +197,42 @@ def test_copy(model):
192197 for fault in copy .faults ():
193198 nb_fault_items += len (copy .fault_items (fault ))
194199 if nb_fault_items != 5 :
195- raise ValueError (
196- "[Test] Number of items in faults in copied model should be 5" )
200+ raise ValueError ("[Test] Number of items in faults in copied model should be 5" )
197201 nb_horizon_items = 0
198202 for horizon in copy .horizons ():
199203 nb_horizon_items += len (copy .horizon_items (horizon ))
200204 if nb_horizon_items != 4 :
201205 raise ValueError (
202- "[Test] Number of items in stratigraphic_units in copied model should be 4" )
206+ "[Test] Number of items in stratigraphic_units in copied model should be 4"
207+ )
203208
204209
205210def modify_model (model , builder ):
206211 horizons_ids = []
207212 for horizon in model .horizons ():
208213 horizons_ids .append (horizon .id ())
209214 builder .set_horizon_contact_type (
210- horizon .id (), geosciences .Horizon3D .CONTACT_TYPE .TOPOGRAPHY )
215+ horizon .id (), geosciences .Horizon3D .CONTACT_TYPE .TOPOGRAPHY
216+ )
211217
212218 for horizon_id in horizons_ids :
213219 builder .remove_horizon (model .horizon (horizon_id ))
214220
215221 for fault in model .faults ():
216- builder .set_fault_type (
217- fault .id (), geosciences .Fault3D .FAULT_TYPE .LISTRIC )
222+ builder .set_fault_type (fault .id (), geosciences .Fault3D .FAULT_TYPE .LISTRIC )
218223 if fault .has_type () == False :
219224 raise ValueError ("[Test] All faults should have a type" )
220225
221226 temp_id = builder .add_fault ()
222227 builder .remove_fault (model .fault (temp_id ))
223228 if model .nb_horizons () != 0 :
224- raise ValueError (
225- "[Test] Number of horizons in modified model should be 0" )
229+ raise ValueError ("[Test] Number of horizons in modified model should be 0" )
226230 if model .nb_faults () != 2 :
227- raise ValueError (
228- "[Test] Number of faults in modified model should be 2" )
231+ raise ValueError ("[Test] Number of faults in modified model should be 2" )
229232
230233
231- if __name__ == ' __main__' :
232- geosciences .GeosciencesExplicitLibrary .initialize ()
234+ if __name__ == " __main__" :
235+ geosciences .OpenGeodeGeosciencesExplicitLibrary .initialize ()
233236 model = geosciences .StructuralModel ()
234237 builder = geosciences .StructuralModelBuilder (model )
235238 add_faults (model , builder )
0 commit comments