Skip to content

Commit

Permalink
fix: adding callback function to builder update
Browse files Browse the repository at this point in the history
this means the progress bar updates for every scalar field that is built
  • Loading branch information
Lachlan Grose committed Sep 14, 2021
1 parent 8effeac commit 1eca6f5
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 5 deletions.
4 changes: 2 additions & 2 deletions LoopStructural/modelling/fault/fault_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -166,6 +166,6 @@ def splayregion(xyz):
def update(self):
for i in range(3):
self.builders[i].update()
def up_to_date(self):
def up_to_date(self, callback=None):
for i in range(3):
self.builders[i].up_to_date()
self.builders[i].up_to_date(callback=callback)
20 changes: 19 additions & 1 deletion LoopStructural/modelling/features/geological_feature_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -87,13 +87,31 @@ def name(self):
def interpolator(self):
return self._interpolator

def up_to_date(self):
def up_to_date(self,callback=None):
"""
check if the feature is uptodate
if its not update.
Parameters
----------
callback : function
a function that is called when the feature is updated
"""
#has anything changed in the builder since we built the feature? if so update
if self._up_to_date == False:
self.update()
if callable(callback):
callback()
return
#check if the interpolator is up to date, if not solve
if self._interpolator.up_to_date == False:
self.update()
if callable(callback):
callback()
return
if callable(callback):
callback()


def add_fault(self, fault):
Expand Down
4 changes: 2 additions & 2 deletions LoopStructural/modelling/features/structural_frame_builder.py
Original file line number Diff line number Diff line change
Expand Up @@ -207,6 +207,6 @@ def build(self, w1=1., w2=1., w3=1., frame=StructuralFrame, **kwargs):
def update(self):
for i in range(3):
self.builders[i].update()
def up_to_date(self):
def up_to_date(self, callback=None):
for i in range(3):
self.builders[i].up_to_date()
self.builders[i].up_to_date(callback=callback)

0 comments on commit 1eca6f5

Please sign in to comment.