Skip to content

Commit

Permalink
style: changing tqdm call order
Browse files Browse the repository at this point in the history
  • Loading branch information
lachlangrose committed Jun 4, 2024
1 parent bf30047 commit f9e918e
Showing 1 changed file with 16 additions and 20 deletions.
36 changes: 16 additions & 20 deletions LoopStructural/modelling/core/geological_model.py
Original file line number Diff line number Diff line change
Expand Up @@ -1731,34 +1731,30 @@ def update(self, verbose=False, progressbar=True):
f"Updating geological model. There are: \n {nfeatures} \
geological features that need to be interpolated\n"
)
import time

start = time.time()
try:
from tqdm.auto import tqdm
except ImportError:
progressbar = False
logger.warning("Failed to import tqdm, disabling progress bar")

if progressbar:
# Load tqdm with size counter instead of file counter
with tqdm(total=nfeatures) as pbar:
for f in self.features:
pbar.set_description(f"Interpolating {f.name}")
f.builder.up_to_date(callback=pbar.update)
else:
for f in self.features:
f.builder.up_to_date()
if verbose:
print(f"Model update took: {time.time()-start} seconds")
try:
from tqdm.auto import tqdm

# Load tqdm with size counter instead of file counter
with tqdm(total=nfeatures) as pbar:
for f in self.features:
pbar.set_description(f"Interpolating {f.name}")
f.builder.up_to_date(callback=pbar.update)
return
except ImportError:
logger.warning("Failed to import tqdm, disabling progress bar")

for f in self.features:
f.builder.up_to_date()

def stratigraphic_ids(self):
"""Return a list of all stratigraphic ids in the model
Returns
-------
ids : list
list of unique stratigraphic ids
list of unique stratigraphic ids, featurename, unit name and min and max scalar values
"""
ids = []
for group in self.stratigraphic_column.keys():
Expand Down Expand Up @@ -1805,7 +1801,7 @@ def get_stratigraphic_surfaces(self, units: List[str] = [], bottoms: bool = True
return surfaces

def get_block_model(self):
grid = self.bounding_box.vtk
grid = self.bounding_box.vtk()

grid.cell_data['stratigraphy'] = self.evaluate_model(
self.bounding_box.cell_centers(), scale=False
Expand Down

0 comments on commit f9e918e

Please sign in to comment.