Skip to content

Commit ef07373

Browse files
committed
fix: add model reference when converting from feature to frame
1 parent e895ab0 commit ef07373

File tree

4 files changed

+24
-2
lines changed

4 files changed

+24
-2
lines changed

.gitignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -135,4 +135,5 @@ docs/source/sg_execution_times.rst
135135
conda/index.html
136136
conda/channeldata.json
137137
conda/noarch
138-
conda/win-64
138+
conda/win-64
139+
.DS_Store

LoopStructural/modelling/features/_feature_converters.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,9 @@
1-
from LoopStructural.modelling.features.fold import FoldEvent
1+
from LoopStructural.modelling.features.fold import FoldEvent, FoldFrame
22
from LoopStructural.modelling.features.builders import FoldedFeatureBuilder, StructuralFrameBuilder
33
def add_fold_to_feature(feature, fold_frame,**kwargs):
4+
if not isinstance(fold_frame, FoldFrame):
5+
raise ValueError("fold_frame must be a FoldFrame instance")
6+
47
fold = FoldEvent(fold_frame, name=f"Fold_{feature.name}", invert_norm=kwargs.get('invert_fold_norm', False))
58

69
builder = FoldedFeatureBuilder.from_feature_builder(

LoopStructural/modelling/features/builders/_structural_frame_builder.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -148,6 +148,7 @@ def from_feature_builder(cls, feature_builder, **kwargs):
148148
bounding_box=feature_builder.model.bounding_box,
149149
nelements=[feature_builder.interpolator.n_elements]*3,
150150
name=feature_builder.name,
151+
model=feature_builder.model,
151152
**kwargs
152153
)
153154
builder.add_data_from_data_frame(feature_builder.data)

LoopStructural/modelling/features/fold/_foldframe.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,24 @@ def __init__(self, name, features, fold=None, model=None):
1919
features
2020
"""
2121
super().__init__(name, features, fold, model)
22+
@classmethod
23+
def from_structural_frame(cls, frame, fold=None):
24+
"""
25+
Create a FoldFrame from an existing StructuralFrame
26+
27+
Parameters
28+
----------
29+
frame - StructuralFrame
30+
the structural frame to convert to a fold frame
31+
fold - FoldEvent, optional
32+
the fold event to associate with the fold frame
2233
34+
Returns
35+
-------
36+
FoldFrame
37+
the new fold frame
38+
"""
39+
return cls(frame.name, frame.features, fold, frame.model)
2340
def calculate_fold_axis_rotation(self, feature_builder, fold_axis=None):
2441
"""
2542
Calculate the fold axis rotation angle by finding the angle between the

0 commit comments

Comments
 (0)