Skip to content
Snippets Groups Projects

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

1 unresolved thread
4 files
+ 88
2
Compare changes
  • Side-by-side
  • Inline
Files
4
+ 14
0
@@ -180,6 +180,13 @@ class Operation(GraphComponent, SignalSourceProvider):
"""
raise NotImplementedError
@abstractmethod
def depends(self, output_index: int, input_index: int) -> bool:
"""Check if the output at the given output index depends on the input at the
given input index in order to be evaluated.
"""
raise NotImplementedError
class AbstractOperation(Operation, AbstractGraphComponent):
"""Generic abstract operation class which most implementations will derive from.
@@ -340,6 +347,13 @@ class AbstractOperation(Operation, AbstractGraphComponent):
pass
return [self]
def depends(self, output_index: int, input_index: int) -> bool:
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})")
if input_index < 0 or input_index >= self.input_count:
raise IndexError(f"Input index out of range (expected 0-{self.input_count - 1}, got {input_index})")
return True # By default, assume each output depends on all inputs.
@property
def neighbors(self) -> Iterable[GraphComponent]:
return list(self.input_signals) + list(self.output_signals)
Loading