Skip to content
Snippets Groups Projects

Add a sink operation to avoid dangling nodes

Merged Hugo Winbladh requested to merge 132-add-a-sink-operation-to-avoid-dangling-nodes into master
2 unresolved threads
1 file
+ 43
1
Compare changes
  • Side-by-side
  • Inline
+ 42
1
@@ -73,7 +73,6 @@ class Constant(AbstractOperation):
@@ -73,7 +73,6 @@ class Constant(AbstractOperation):
def __str__(self) -> str:
def __str__(self) -> str:
return f"{self.value}"
return f"{self.value}"
class Addition(AbstractOperation):
class Addition(AbstractOperation):
"""
"""
Binary addition operation.
Binary addition operation.
@@ -1263,3 +1262,45 @@ class Shift(AbstractOperation):
@@ -1263,3 +1262,45 @@ class Shift(AbstractOperation):
if not isinstance(value, int):
if not isinstance(value, int):
raise TypeError("value must be an int")
raise TypeError("value must be an int")
self.set_param("value", value)
self.set_param("value", value)
 
 
class Sink(AbstractOperation):
 
r"""
 
Sink operation.
 
 
Used for ignoring the output from another operation to avoid dangling output nodes.
 
 
Parameters
 
==========
 
 
name : Name, optional
 
Operation name.
 
"""
 
 
_execution_time = 0
 
is_linear = True
 
 
def __init__(self, name: Name = ""):
 
"""Construct a Sink operation."""
 
super().__init__(
 
input_count=1,
 
output_count=0,
 
name=name,
 
latency_offsets={"in0": 0},
 
)
 
 
@classmethod
 
def type_name(cls) -> TypeName:
 
return TypeName("sink")
 
 
def evaluate(self):
 
raise NotImplementedError
 
Please register or sign in to reply
 
@property
 
def latency(self) -> int:
 
return self.latency_offsets["in0"]
    • Probably this can be hardcoded to a suitable value (like 0).

      • Author Contributor

        The latency is kind of hard-coded to 0 already since the constructor sets the latency_offsets to {'in0': 0}. However the code may be more readable if the latency function explicitly always returns 0.

      • Please register or sign in to reply
Please register or sign in to reply
 
 
def __repr__(self) -> str:
 
return "Sink()"
 
 
def __str__(self) -> str:
 
return "sink"
Loading