Skip to content
This repository has been archived by the owner on Nov 7, 2024. It is now read-only.

Commit

Permalink
Merge branch 'main' into start_removing_the_faux_functional_style_code
Browse files Browse the repository at this point in the history
  • Loading branch information
mattclarke authored Nov 23, 2023
2 parents 1a3ce5f + 41aa05c commit a9b180b
Show file tree
Hide file tree
Showing 2 changed files with 0 additions and 43 deletions.
28 changes: 0 additions & 28 deletions nexus_constructor/model/group.py
Original file line number Diff line number Diff line change
Expand Up @@ -89,34 +89,6 @@ def has_pixel_shape(self):
def number_of_children(self):
return len(self.children)

def tree_depth(self):
"""
The depth of the tree.
"""
return self._apply_function_to_tree_structure(max)

def tree_size(self):
"""
Number of nodes in the tree structure.
"""
return self._apply_function_to_tree_structure(sum)

def _apply_function_to_tree_structure(self, func):
if not self.children:
return 1
else:
return (
func(
[
child._apply_function_to_tree_structure(func)
if isinstance(child, Group)
else 1
for child in self.children
]
)
+ 1
)

@property
def absolute_path(self):
return get_absolute_path(self)
Expand Down
15 changes: 0 additions & 15 deletions tests/model/test_group.py
Original file line number Diff line number Diff line change
Expand Up @@ -44,18 +44,3 @@ def test_group_as_dict_contains_expected_keys():
assert expected_key in dictionary_output.keys()

assert dictionary_output["name"] == input_name


def test_group_depth_returns_expected_tree_depth():
entry, sample, instrument = create_tree_structure()

assert entry.tree_depth() == 4
assert sample.tree_depth() == 3
assert instrument.tree_depth() == 2


def test_group_size_returns_expected_tree_size():
entry, sample, instrument = create_tree_structure()
assert entry.tree_size() == 9
assert sample.tree_size() == 5
assert instrument.tree_size() == 3

0 comments on commit a9b180b

Please sign in to comment.