Skip to content
Snippets Groups Projects
Commit b06f21cd authored by Oscar Gustafsson's avatar Oscar Gustafsson :bicyclist:
Browse files

Import from correct location

parent 8d22803d
No related branches found
No related tags found
1 merge request!208Minor fixes
...@@ -5,12 +5,8 @@ Contains the class for representing the connections between operations. ...@@ -5,12 +5,8 @@ Contains the class for representing the connections between operations.
""" """
from typing import TYPE_CHECKING, Iterable, Optional, Union from typing import TYPE_CHECKING, Iterable, Optional, Union
from b_asic.graph_component import ( from b_asic.graph_component import AbstractGraphComponent, GraphComponent
AbstractGraphComponent, from b_asic.types import Name, TypeName
GraphComponent,
Name,
TypeName,
)
if TYPE_CHECKING: if TYPE_CHECKING:
from b_asic.operation import Operation from b_asic.operation import Operation
...@@ -48,9 +44,7 @@ class Signal(AbstractGraphComponent): ...@@ -48,9 +44,7 @@ class Signal(AbstractGraphComponent):
def __init__( def __init__(
self, self,
source: Optional[Union["OutputPort", "Signal", "Operation"]] = None, source: Optional[Union["OutputPort", "Signal", "Operation"]] = None,
destination: Optional[ destination: Optional[Union["InputPort", "Signal", "Operation"]] = None,
Union["InputPort", "Signal", "Operation"]
] = None,
bits: Optional[int] = None, bits: Optional[int] = None,
name: Name = Name(""), name: Name = Name(""),
): ):
...@@ -70,11 +64,7 @@ class Signal(AbstractGraphComponent): ...@@ -70,11 +64,7 @@ class Signal(AbstractGraphComponent):
@property @property
def neighbors(self) -> Iterable[GraphComponent]: def neighbors(self) -> Iterable[GraphComponent]:
return [ return [p.operation for p in [self.source, self.destination] if p is not None]
p.operation
for p in [self.source, self.destination]
if p is not None
]
@property @property
def source(self) -> Optional["OutputPort"]: def source(self) -> Optional["OutputPort"]:
...@@ -86,9 +76,7 @@ class Signal(AbstractGraphComponent): ...@@ -86,9 +76,7 @@ class Signal(AbstractGraphComponent):
"""The destination InputPort of the signal.""" """The destination InputPort of the signal."""
return self._destination return self._destination
def set_source( def set_source(self, source: Union["OutputPort", "Signal", "Operation"]) -> None:
self, source: Union["OutputPort", "Signal", "Operation"]
) -> None:
""" """
Disconnect the previous source OutputPort of the signal and Disconnect the previous source OutputPort of the signal and
connect to the entered source OutputPort. Also connect the entered connect to the entered source OutputPort. Also connect the entered
...@@ -197,9 +185,7 @@ class Signal(AbstractGraphComponent): ...@@ -197,9 +185,7 @@ class Signal(AbstractGraphComponent):
""" """
if bits is not None: if bits is not None:
if not isinstance(bits, int): if not isinstance(bits, int):
raise TypeError( raise TypeError(f"Bits must be an int, not {type(bits)}: {bits!r}")
f"Bits must be an int, not {type(bits)}: {bits!r}"
)
if bits < 0: if bits < 0:
raise ValueError("Bits cannot be negative") raise ValueError("Bits cannot be negative")
self.set_param("bits", bits) self.set_param("bits", bits)
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment