From d5c116016c0ffd95622ec177820015216ecf7b9e Mon Sep 17 00:00:00 2001 From: drodarie Date: Thu, 1 Aug 2024 14:49:16 +0200 Subject: [PATCH] fix: drop stack_order and fix documentation --- bsb/topology/region.py | 25 +++--------------------- docs/getting-started/getting-started.rst | 2 +- docs/getting-started/include_morphos.rst | 4 ++-- tests/test_topology.py | 17 ---------------- 4 files changed, 6 insertions(+), 42 deletions(-) diff --git a/bsb/topology/region.py b/bsb/topology/region.py index fa9d090cb..4644cabbd 100644 --- a/bsb/topology/region.py +++ b/bsb/topology/region.py @@ -85,34 +85,16 @@ def scale(self, factors): @config.node class Stack(RegionGroup, classmap_entry="stack"): """ - Stack components on top of each other based on their ``stack_order`` if it is defined - and adjust its own height accordingly. + Stack components on top of each other and adjust its own height accordingly. """ axis: typing.Union[typing.Literal["x"], typing.Literal["y"], typing.Literal["z"]] = ( config.attr(type=types.in_(["x", "y", "z"]), default="z") ) - stack_order: list[typing.Union["Region", "Partition"]] = config.reflist( - refs.regional_ref, backref="region" - ) anchor: typing.Union["Region", "Partition"] = config.ref( refs.regional_ref, backref="region" ) - def _resolve_stack_order(self, layout): - corrected_order = [] - children_owners = [child._owner for child in layout.children] - for child in self.stack_order: - if child in children_owners: - to_add = layout.children[children_owners.index(child)] - if to_add not in corrected_order: - corrected_order.append(to_add) - - for child in layout.children: - if child not in corrected_order: - corrected_order.append(child) - return corrected_order - def _resolve_anchor_offset(self, children, axis_idx): children_owners = [child._owner for child in children] if self.anchor is not None and self.anchor in children_owners: @@ -129,10 +111,9 @@ def get_layout(self, hint): trans_eye = np.zeros(3) trans_eye[axis_idx] = 1 - children = self._resolve_stack_order(layout) # origin of stack corresponds to the origin of the first child - cumul_offset = self._resolve_anchor_offset(children, axis_idx) - for child in children: + cumul_offset = self._resolve_anchor_offset(layout.children, axis_idx) + for child in layout.children: if child.data is None: warn(f"Skipped layout arrangement of {child._owner.name} in {self.name}") continue diff --git a/docs/getting-started/getting-started.rst b/docs/getting-started/getting-started.rst index b3aa26c24..756a9f31e 100644 --- a/docs/getting-started/getting-started.rst +++ b/docs/getting-started/getting-started.rst @@ -150,7 +150,7 @@ Connectivity .. literalinclude:: getting-started.json :language: json - :lines: 56-66 + :lines: 54-64 .. literalinclude:: getting_started.py :language: python diff --git a/docs/getting-started/include_morphos.rst b/docs/getting-started/include_morphos.rst index 1afaaff1b..9ff38fcc6 100644 --- a/docs/getting-started/include_morphos.rst +++ b/docs/getting-started/include_morphos.rst @@ -163,11 +163,11 @@ connection strategies such as :class:`~.connectivity.detailed.voxel_intersection .. literalinclude:: include_morphos.yaml :language: yaml - :lines: 56-64 + :lines: 54-62 .. literalinclude:: include_morphos.json :language: json - :lines: 74-84 + :lines: 72-82 .. literalinclude:: include_morphos.py :language: python diff --git a/tests/test_topology.py b/tests/test_topology.py index 7a7ea01c7..c63eb3df7 100644 --- a/tests/test_topology.py +++ b/tests/test_topology.py @@ -135,23 +135,6 @@ def test_default_order(self): network = Scaffold(Configuration.default(**self.cfg), self.storage) self._test_dimensions_offset(np.array(network.regions["a"].children)) - def test_stack_order(self): - self.cfg["regions"]["a"]["stack_order"] = [ - "layer0", - "layer1", - "layer1", - "layer2", - "rhomboid1", - "rhomboid2", - ] - expected_order = ["layer1", "layer2", "rhomboid1", "rhomboid2", "rhomboid3"] - expected_index = np.array([3, 1, 0, 2, 4]) - network = Scaffold(Configuration.default(**self.cfg), self.storage) - for i, child in enumerate( - np.array(network.regions["a"].children)[expected_index] - ): - self.assertEqual(child.name, expected_order[i]) - def test_anchor(self): self.cfg["regions"]["a"]["anchor"] = "layer2" network = Scaffold(Configuration.default(**self.cfg), self.storage)