-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Lachlan Grose
committed
Sep 28, 2022
1 parent
9cb79cb
commit 3480e3d
Showing
4 changed files
with
137 additions
and
80 deletions.
There are no files selected for viewing
79 changes: 79 additions & 0 deletions
79
LoopStructural/modelling/features/builders/_base_builder.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,79 @@ | ||
class BaseBuilder: | ||
def __init__(self, name="Feature"): | ||
self._name = name | ||
self._feature = None | ||
self._feature = None | ||
self._up_to_date = False | ||
self._build_arguments = {} | ||
self.faults = [] | ||
|
||
@property | ||
def feature(self): | ||
return self._feature | ||
|
||
@property | ||
def build_arguments(self): | ||
return self._build_arguments | ||
|
||
@build_arguments.setter | ||
def build_arguments(self, build_arguments): | ||
# self._build_arguments = {} | ||
for k, i in build_arguments.items(): | ||
if i != self._build_arguments.get(k, None): | ||
self._build_arguments[k] = i | ||
## if build_arguments change then flag to reinterpolate | ||
self._up_to_date = False | ||
|
||
def update(self): | ||
self.build(**self.build_arguments) | ||
|
||
def build(self,**kwargs): | ||
raise NotImplementedError('BaseBuilder should be inherited and build method overwritten') | ||
|
||
@property | ||
def name(self): | ||
return self._name | ||
|
||
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 | ||
""" | ||
for f in self.faults: | ||
f.builder.up_to_date(callback=callback) | ||
# 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(1) | ||
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(1) | ||
return | ||
if callable(callback): | ||
callback(1) | ||
|
||
def add_fault(self, fault): | ||
""" | ||
Add a fault to the geological feature builder | ||
Parameters | ||
---------- | ||
fault : FaultSegment | ||
A faultsegment to add to the geological feature | ||
Returns | ||
------- | ||
""" | ||
self._up_to_date = False | ||
self.faults.append(fault) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,45 @@ | ||
import pytest | ||
from LoopStructural.modelling.features.builders import GeologicalFeatureBuilder | ||
|
||
def test_geological_feature_builder_constructor(): | ||
interpolator = | ||
builder = GeologicalFeatureBuilder() | ||
pass | ||
|
||
def test_get_interpolator(): | ||
pass | ||
|
||
def test_add_data_to_interpolator(): | ||
pass | ||
|
||
def test_install_gradient_constraints(): | ||
pass | ||
|
||
def test_get_value_constraints(): | ||
pass | ||
|
||
def test_get_gradient_constraints(): | ||
pass | ||
|
||
def test_get_tangent_constraints(): | ||
pass | ||
|
||
def test_norm_constraints(): | ||
pass | ||
|
||
def get_orientation_constraints(): | ||
pass | ||
|
||
def get_data_locations(): | ||
pass | ||
|
||
def test_test_interpolation_geometry(): | ||
pass | ||
|
||
def test_not_up_to_date(): | ||
"""test to make sure that the feature | ||
isn't interpolated when everything is set up | ||
""" | ||
pass | ||
def test_get_feature(): | ||
pass |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters