Skip to content
Snippets Groups Projects

Resolve "Specify internal input/output dependencies of an Operation"

1 unresolved thread
Files
4
+ 10
0
@@ -180,6 +180,11 @@ class Operation(GraphComponent, SignalSourceProvider):
@@ -180,6 +180,11 @@ class Operation(GraphComponent, SignalSourceProvider):
"""
"""
raise NotImplementedError
raise NotImplementedError
 
@abstractmethod
 
def inputs_required_for_output(self, output_index: int) -> Iterable[int]:
 
"""Get the input indices of all inputs in this operation whose values are required in order to evalueate the output at the given output index."""
 
raise NotImplementedError
 
class AbstractOperation(Operation, AbstractGraphComponent):
class AbstractOperation(Operation, AbstractGraphComponent):
"""Generic abstract operation class which most implementations will derive from.
"""Generic abstract operation class which most implementations will derive from.
@@ -340,6 +345,11 @@ class AbstractOperation(Operation, AbstractGraphComponent):
@@ -340,6 +345,11 @@ class AbstractOperation(Operation, AbstractGraphComponent):
pass
pass
return [self]
return [self]
 
def inputs_required_for_output(self, output_index: int) -> Iterable[int]:
 
if output_index < 0 or output_index >= self.output_count:
 
raise IndexError(f"Output index out of range (expected 0-{self.output_count - 1}, got {output_index})")
 
return [i for i in range(self.input_count)] # By default, assume each output depends on all inputs.
 
@property
@property
def neighbors(self) -> Iterable[GraphComponent]:
def neighbors(self) -> Iterable[GraphComponent]:
return list(self.input_signals) + list(self.output_signals)
return list(self.input_signals) + list(self.output_signals)
Loading