Skip to content
Snippets Groups Projects
Commit 3dbb4ab9 authored by Ivar Härnqvist's avatar Ivar Härnqvist
Browse files

Misc. fixes

parent 7c6cbe75
No related branches found
No related tags found
3 merge requests!67WIP: B-ASIC version 1.0.0 hotfix,!65B-ASIC version 1.0.0,!15Add changes from sprint 1 and 2 to master
......@@ -35,7 +35,7 @@ class Constant(AbstractOperation):
self._output_ports = [OutputPort(0, self)]
self._parameters["value"] = value
def evaluate(self) -> Any:
def evaluate(self):
return self.param("value")
@property
......@@ -59,7 +59,7 @@ class Addition(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
return a + b
@property
......@@ -82,11 +82,11 @@ class Subtraction(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
return a - b
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "sub"
......@@ -105,11 +105,11 @@ class Multiplication(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
return a * b
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "mul"
......@@ -128,11 +128,11 @@ class Division(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
return a / b
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "div"
......@@ -150,11 +150,11 @@ class SquareRoot(AbstractOperation):
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return sqrt((complex)(a))
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "sqrt"
......@@ -172,11 +172,11 @@ class ComplexConjugate(AbstractOperation):
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return conjugate(a)
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "conj"
......@@ -195,13 +195,13 @@ class Max(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
assert not isinstance(a, complex) and not isinstance(b, complex), \
("core_operation.Max does not support complex numbers.")
("core_operations.Max does not support complex numbers.")
return a if a > b else b
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "max"
......@@ -220,13 +220,13 @@ class Min(AbstractOperation):
if source2 is not None:
self._input_ports[1].connect_to_port(source2)
def evaluate(self, a, b) -> Any:
def evaluate(self, a, b):
assert not isinstance(a, complex) and not isinstance(b, complex), \
("core_operation.Min does not support complex numbers.")
("core_operations.Min does not support complex numbers.")
return a if a < b else b
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "min"
......@@ -244,11 +244,11 @@ class Absolute(AbstractOperation):
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return np_abs(a)
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "abs"
......@@ -266,7 +266,7 @@ class ConstantMultiplication(AbstractOperation):
if source1 is not None:
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return a * self.param("coefficient")
@property
......@@ -288,11 +288,11 @@ class ConstantAddition(AbstractOperation):
if source1 is not None:
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return a + self.param("coefficient")
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "cadd"
......@@ -310,11 +310,11 @@ class ConstantSubtraction(AbstractOperation):
if source1 is not None:
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return a - self.param("coefficient")
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "csub"
......@@ -332,9 +332,9 @@ class ConstantDivision(AbstractOperation):
if source1 is not None:
self._input_ports[0].connect_to_port(source1)
def evaluate(self, a) -> Any:
def evaluate(self, a):
return a / self.param("coefficient")
@property
def type_name(self) -> GraphIDType:
def type_name(self) -> TypeName:
return "cdiv"
......@@ -86,9 +86,9 @@ class Operation(GraphComponent):
@property
@abstractmethod
def neighbours(self) -> "List[Operation]":
def neighbors(self) -> "List[Operation]":
"""Return all operations that are connected by signals to this operation.
If no neighbours are found this returns an empty list
If no neighbors are found, this returns an empty list.
"""
raise NotImplementedError
......@@ -175,17 +175,17 @@ class AbstractOperation(Operation, AbstractGraphComponent):
return [self]
@property
def neighbours(self) -> List[Operation]:
neighbours: List[Operation] = []
def neighbors(self) -> List[Operation]:
neighbors: List[Operation] = []
for port in self._input_ports:
for signal in port.signals:
neighbours.append(signal.source.operation)
neighbors.append(signal.source.operation)
for port in self._output_ports:
for signal in port.signals:
neighbours.append(signal.destination.operation)
neighbors.append(signal.destination.operation)
return neighbours
return neighbors
def traverse(self) -> Operation:
"""Traverse the operation tree and return a generator with start point in the operation."""
......@@ -198,7 +198,7 @@ class AbstractOperation(Operation, AbstractGraphComponent):
while queue:
operation = queue.popleft()
yield operation
for n_operation in operation.neighbours:
for n_operation in operation.neighbors:
if n_operation not in visited:
visited.add(n_operation)
queue.append(n_operation)
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