Skip to content

Commit e42cf35

Browse files
committed
style: autoformat
1 parent 834d3a4 commit e42cf35

1 file changed

Lines changed: 31 additions & 43 deletions

File tree

LoopStructural/modelling/core/geological_model.py

Lines changed: 31 additions & 43 deletions
Original file line numberDiff line numberDiff line change
@@ -61,14 +61,11 @@ class GeologicalModel:
6161
the origin of the model box
6262
parameters : dict
6363
a dictionary tracking the parameters used to build the model
64-
64+
6565
6666
"""
6767

68-
def __init__(
69-
self,
70-
*args
71-
):
68+
def __init__(self, *args):
7269
"""
7370
Parameters
7471
----------
@@ -78,7 +75,7 @@ def __init__(
7875
the origin of the model
7976
maximum : np.array(3,dtype=doubles)
8077
the maximum of the model
81-
78+
8279
Examples
8380
--------
8481
Demo data
@@ -148,7 +145,6 @@ def to_dict(self):
148145
# json["features"] = [f.to_json() for f in self.features]
149146
return json
150147

151-
152148
def __str__(self):
153149
return f"GeologicalModel with {len(self.features)} features"
154150

@@ -189,6 +185,7 @@ def prepare_data(self, data: pd.DataFrame) -> pd.DataFrame:
189185
['X', 'Y', 'Z', 'val', 'nx', 'ny', 'nz', 'gx', 'gy', 'gz', 'tx', 'ty', 'tz']
190186
].astype(float)
191187
return data
188+
192189
@classmethod
193190
def from_processor(cls, processor):
194191
"""Builds a model from a :class:`LoopStructural.modelling.input.ProcessInputData` object
@@ -380,8 +377,6 @@ def fault_names(self):
380377
"""
381378
return [f.name for f in self.faults]
382379

383-
384-
385380
def to_file(self, file):
386381
"""Save a model to a pickle file requires dill
387382
@@ -478,8 +473,6 @@ def data(self, data: pd.DataFrame):
478473
self._data = data.copy()
479474
# self._data[['X','Y','Z']] = self.bounding_box.project(self._data[['X','Y','Z']].to_numpy())
480475

481-
482-
483476
def set_model_data(self, data):
484477
logger.warning("deprecated method. Model data can now be set using the data attribute")
485478
self.data = data.copy()
@@ -509,18 +502,22 @@ def set_stratigraphic_column(self, stratigraphic_column, cmap="tab20"):
509502
# if the colour for a unit hasn't been specified we can just sample from
510503
# a colour map e.g. tab20
511504
logger.info("Adding stratigraphic column to model")
512-
DeprecationWarning("set_stratigraphic_column is deprecated, use model.stratigraphic_column.add_units instead")
505+
DeprecationWarning(
506+
"set_stratigraphic_column is deprecated, use model.stratigraphic_column.add_units instead"
507+
)
513508
for g in stratigraphic_column.keys():
514509
for u in stratigraphic_column[g].keys():
515510
thickness = 0
516511
if "min" in stratigraphic_column[g][u] and "max" in stratigraphic_column[g][u]:
517512
min_val = stratigraphic_column[g][u]["min"]
518513
max_val = stratigraphic_column[g][u].get("max", None)
519514
thickness = max_val - min_val if max_val is not None else None
520-
logger.warning(f"""
515+
logger.warning(
516+
f"""
521517
model.stratigraphic_column.add_unit({u},
522518
colour={stratigraphic_column[g][u].get("colour", None)},
523-
thickness={thickness})""")
519+
thickness={thickness})"""
520+
)
524521
self.stratigraphic_column.add_unit(
525522
u,
526523
colour=stratigraphic_column[g][u].get("colour", None),
@@ -529,7 +526,6 @@ def set_stratigraphic_column(self, stratigraphic_column, cmap="tab20"):
529526
self.stratigraphic_column.add_unconformity(
530527
name=''.join([g, 'unconformity']),
531528
)
532-
533529

534530
def create_and_add_foliation(
535531
self,
@@ -576,7 +572,7 @@ def create_and_add_foliation(
576572
An interpolator will be chosen by calling :meth:`LoopStructural.GeologicalModel.get_interpolator`
577573
578574
"""
579-
575+
580576
# if tol is not specified use the model default
581577
if tol is None:
582578
tol = self.tol
@@ -612,7 +608,7 @@ def create_and_add_foliation(
612608

613609
def create_and_add_fold_frame(
614610
self,
615-
fold_frame_name:str,
611+
fold_frame_name: str,
616612
*,
617613
fold_frame_data=None,
618614
interpolatortype="FDI",
@@ -641,14 +637,14 @@ def create_and_add_fold_frame(
641637
:class:`LoopStructural.modelling.features.builders.StructuralFrameBuilder`
642638
and :meth:`LoopStructural.modelling.features.builders.StructuralFrameBuilder.setup`
643639
and the interpolator, such as `domain` or `tol`
644-
640+
645641
646642
Returns
647643
-------
648644
fold_frame : FoldFrame
649645
the created fold frame
650646
"""
651-
647+
652648
if tol is None:
653649
tol = self.tol
654650

@@ -724,7 +720,7 @@ def create_and_add_folded_foliation(
724720
:class:`LoopStructural.modelling.features.builders.FoldedFeatureBuilder`
725721
726722
"""
727-
723+
728724
if tol is None:
729725
tol = self.tol
730726

@@ -753,11 +749,7 @@ def create_and_add_folded_foliation(
753749
if foliation_data.shape[0] == 0:
754750
logger.warning(f"No data for {foliation_name}, skipping")
755751
return
756-
series_builder.add_data_from_data_frame(
757-
self.prepare_data(
758-
foliation_data
759-
)
760-
)
752+
series_builder.add_data_from_data_frame(self.prepare_data(foliation_data))
761753
self._add_faults(series_builder)
762754
# series_builder.add_data_to_interpolator(True)
763755
# build feature
@@ -824,7 +816,7 @@ def create_and_add_folded_fold_frame(
824816
see :class:`LoopStructural.modelling.features.fold.FoldEvent`,
825817
:class:`LoopStructural.modelling.features.builders.FoldedFeatureBuilder`
826818
"""
827-
819+
828820
if tol is None:
829821
tol = self.tol
830822

@@ -1151,7 +1143,7 @@ def add_onlap_unconformity(self, feature: GeologicalFeature, value: float) -> Ge
11511143
return uc_feature
11521144

11531145
def create_and_add_domain_fault(
1154-
self, fault_surface_data,*, nelements=10000, interpolatortype="FDI", **kwargs
1146+
self, fault_surface_data, *, nelements=10000, interpolatortype="FDI", **kwargs
11551147
):
11561148
"""
11571149
Parameters
@@ -1205,7 +1197,7 @@ def create_and_add_fault(
12051197
fault_name: str,
12061198
displacement: float,
12071199
*,
1208-
fault_data:Optional[pd.DataFrame] = None,
1200+
fault_data: Optional[pd.DataFrame] = None,
12091201
interpolatortype="FDI",
12101202
tol=None,
12111203
fault_slip_vector=None,
@@ -1290,7 +1282,7 @@ def create_and_add_fault(
12901282
if "data_region" in kwargs:
12911283
kwargs.pop("data_region")
12921284
logger.error("kwarg data_region currently not supported, disabling")
1293-
displacement_scaled = displacement
1285+
displacement_scaled = displacement
12941286
fault_frame_builder = FaultBuilder(
12951287
interpolatortype,
12961288
bounding_box=self.bounding_box,
@@ -1311,11 +1303,11 @@ def create_and_add_fault(
13111303
if fault_center is not None and ~np.isnan(fault_center).any():
13121304
fault_center = self.scale(fault_center, inplace=False)
13131305
if minor_axis:
1314-
minor_axis = minor_axis
1306+
minor_axis = minor_axis
13151307
if major_axis:
1316-
major_axis = major_axis
1308+
major_axis = major_axis
13171309
if intermediate_axis:
1318-
intermediate_axis = intermediate_axis
1310+
intermediate_axis = intermediate_axis
13191311
fault_frame_builder.create_data_from_geometry(
13201312
fault_frame_data=self.prepare_data(fault_data),
13211313
fault_center=fault_center,
@@ -1371,7 +1363,7 @@ def rescale(self, points: np.ndarray, *, inplace: bool = False) -> np.ndarray:
13711363
13721364
"""
13731365

1374-
return self.bounding_box.reproject(points,inplace=inplace)
1366+
return self.bounding_box.reproject(points, inplace=inplace)
13751367

13761368
# TODO move scale to bounding box/transformer
13771369
def scale(self, points: np.ndarray, *, inplace: bool = False) -> np.ndarray:
@@ -1389,7 +1381,7 @@ def scale(self, points: np.ndarray, *, inplace: bool = False) -> np.ndarray:
13891381
points : np.a::rray((N,3),dtype=double)
13901382
13911383
"""
1392-
return self.bounding_box.project(np.array(points).astype(float),inplace=inplace)
1384+
return self.bounding_box.project(np.array(points).astype(float), inplace=inplace)
13931385

13941386
def regular_grid(self, *, nsteps=None, shuffle=True, rescale=False, order="C"):
13951387
"""
@@ -1538,7 +1530,7 @@ def evaluate_fault_displacements(self, points, scale=True):
15381530
if f.type == FeatureType.FAULT:
15391531
disp = f.displacementfeature.evaluate_value(points)
15401532
vals[~np.isnan(disp)] += disp[~np.isnan(disp)]
1541-
return vals # convert from restoration magnutude to displacement
1533+
return vals # convert from restoration magnutude to displacement
15421534

15431535
def get_feature_by_name(self, feature_name) -> GeologicalFeature:
15441536
"""Returns a feature from the mode given a name
@@ -1713,14 +1705,10 @@ def get_stratigraphic_surfaces(self, units: List[str] = [], bottoms: bool = True
17131705
logger.warning(f"Group {u['group']} not found in model")
17141706
continue
17151707
feature = self.get_feature_by_name(u['group'])
1716-
1717-
surfaces.extend(feature.surfaces([u['value']],
1718-
self.bounding_box,
1719-
name=name,
1720-
colours=[u['colour']]
1721-
))
1722-
1723-
1708+
1709+
surfaces.extend(
1710+
feature.surfaces([u['value']], self.bounding_box, name=name, colours=[u['colour']])
1711+
)
17241712

17251713
return surfaces
17261714

0 commit comments

Comments
 (0)