Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Composition: fix TERMINAL node detection #2384

Merged
merged 1 commit into from
Apr 12, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 4 additions & 1 deletion psyneulink/core/compositions/composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -4566,7 +4566,10 @@ def _determine_origin_and_terminal_nodes_from_consideration_queue(self):
# consideration set. Identifying these assumes that graph_processing has been called/updated,
# which identifies and "breaks" cycles, and assigns FEEDBACK_SENDER to the appropriate consideration set(s).
for node in self.nodes:
if not any([efferent for efferent in node.efferents if efferent.receiver.owner is not self.output_CIM]):
if not any([
efferent.is_active_in_composition(self) for efferent in node.efferents
if efferent.receiver.owner is not self.output_CIM
]):
self._add_node_role(node, NodeRole.TERMINAL)

def _add_node_aux_components(self, node, context=None):
Expand Down
11 changes: 11 additions & 0 deletions tests/composition/test_composition.py
Original file line number Diff line number Diff line change
Expand Up @@ -7351,6 +7351,17 @@ def test_controller_role(self):
assert comp.get_nodes_by_role(NodeRole.CONTROLLER) == [comp.controller]
assert comp.nodes_to_roles[comp.controller] == {NodeRole.CONTROLLER}

def test_inactive_terminal_projection(self):
A = pnl.ProcessingMechanism(name='A')
B = pnl.ProcessingMechanism(name='B')
C = pnl.ProcessingMechanism(name='C')
D = pnl.ProcessingMechanism(name='D')

pnl.MappingProjection(sender=A, receiver=D)
comp = pnl.Composition([[A],[B,C]])

assert comp.nodes_to_roles[A] == {NodeRole.INPUT, NodeRole.OUTPUT, NodeRole.SINGLETON, NodeRole.ORIGIN, NodeRole.TERMINAL}


class TestMisc:

Expand Down