Skip to content

Commit

Permalink
fix: 🐛 fault function attribute is now a property accessor
Browse files Browse the repository at this point in the history
prevents an invalid object being used as a fault function
  • Loading branch information
Lachlan Grose committed Apr 27, 2022
1 parent 56ac223 commit 3b9cc2e
Showing 1 changed file with 14 additions and 3 deletions.
17 changes: 14 additions & 3 deletions LoopStructural/modelling/features/fault/_fault_segment.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,9 +38,7 @@ def __init__(
StructuralFrame.__init__(self, features, name, fold)
self.type = "fault"
self.displacement = displacement
self.faultfunction = faultfunction
if faultfunction == "BaseFault":
self.faultfunction = BaseFault.fault_displacement
self._faultfunction = BaseFault.fault_displacement
self.steps = steps
self.regions = []
self.faults_enabled = True
Expand All @@ -50,6 +48,19 @@ def __init__(
self.splay = {}
self.abut = {}

@property
def faultfunction(self):
return self._faultfunction

@faultfunction.setter
def faultfunction(self, value):
if callable(value):
self.faultfunction = value
elif isinstance(value, str) and value == "BaseFault":
self._faultfunction = BaseFault.fault_displacement
else:
raise ValueError("Fault function must be a function or BaseFault")

@property
def fault_normal_vector(self):
if self.builder == None:
Expand Down

0 comments on commit 3b9cc2e

Please sign in to comment.