Skip to content

Commit

Permalink
Added comments by @ndaelman-hu and @JFRudzinski
Browse files Browse the repository at this point in the history
Added utils folder

Improved normalization for Symmetry
  • Loading branch information
JosePizarro3 committed Feb 9, 2024
1 parent 395ee17 commit 579d70e
Show file tree
Hide file tree
Showing 4 changed files with 181 additions and 121 deletions.
14 changes: 8 additions & 6 deletions simulationdataschema/general.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,10 +69,12 @@ class Simulation(BaseSimulation, EntryData):

outputs = SubSection(sub_section=Outputs.m_def, repeats=True)

def _set_system_tree_index(self, system_parent: ModelSystem, tree_index: int = 0):
def _set_system_branch_depth(
self, system_parent: ModelSystem, branch_depth: int = 0
):
for system_child in system_parent.model_system:
system_child.tree_index = tree_index + 1
self._set_system_tree_index(system_child, tree_index + 1)
system_child.branch_depth = branch_depth + 1
self._set_system_branch_depth(system_child, branch_depth + 1)

def normalize(self, archive, logger) -> None:
super(EntryData, self).normalize(archive, logger)
Expand All @@ -87,9 +89,9 @@ def normalize(self, archive, logger) -> None:
system_ref.is_representative = True
self.m_cache["system_ref"] = system_ref

# Setting up the `tree_index` in the parent-child tree
# Setting up the `branch_depth` in the parent-child tree
for system_parents in self.model_system:
system_parents.tree_index = 0
system_parents.branch_depth = 0
if len(system_parents.model_system) == 0:
continue
self._set_system_tree_index(system_parents)
self._set_system_branch_depth(system_parents)
Loading

0 comments on commit 579d70e

Please sign in to comment.