Skip to content
Snippets Groups Projects

Name literals

Merged Frans Skarman requested to merge name_literals into master
7 files
+ 166
138
Compare changes
  • Side-by-side
  • Inline
Files
7
+ 12
12
@@ -4,7 +4,6 @@ B-ASIC Core Operations Module.
@@ -4,7 +4,6 @@ B-ASIC Core Operations Module.
Contains some of the most commonly used mathematical operations.
Contains some of the most commonly used mathematical operations.
"""
"""
from numbers import Number
from typing import Dict, Optional
from typing import Dict, Optional
from numpy import abs as np_abs
from numpy import abs as np_abs
@@ -13,6 +12,7 @@ from numpy import conjugate, sqrt
@@ -13,6 +12,7 @@ from numpy import conjugate, sqrt
from b_asic.graph_component import Name, TypeName
from b_asic.graph_component import Name, TypeName
from b_asic.operation import AbstractOperation
from b_asic.operation import AbstractOperation
from b_asic.port import SignalSourceProvider
from b_asic.port import SignalSourceProvider
 
from b_asic.types import Num
class Constant(AbstractOperation):
class Constant(AbstractOperation):
@@ -35,12 +35,12 @@ class Constant(AbstractOperation):
@@ -35,12 +35,12 @@ class Constant(AbstractOperation):
_execution_time = 0
_execution_time = 0
def __init__(self, value: Number = 0, name: Name = Name("")):
def __init__(self, value: Num = 0, name: Name = ""):
"""Construct a Constant operation with the given value."""
"""Construct a Constant operation with the given value."""
super().__init__(
super().__init__(
input_count=0,
input_count=0,
output_count=1,
output_count=1,
name=Name(name),
name=name,
latency_offsets={"out0": 0},
latency_offsets={"out0": 0},
)
)
self.set_param("value", value)
self.set_param("value", value)
@@ -53,12 +53,12 @@ class Constant(AbstractOperation):
@@ -53,12 +53,12 @@ class Constant(AbstractOperation):
return self.param("value")
return self.param("value")
@property
@property
def value(self) -> Number:
def value(self) -> Num:
"""Get the constant value of this operation."""
"""Get the constant value of this operation."""
return self.param("value")
return self.param("value")
@value.setter
@value.setter
def value(self, value: Number) -> None:
def value(self, value: Num) -> None:
"""Set the constant value of this operation."""
"""Set the constant value of this operation."""
self.set_param("value", value)
self.set_param("value", value)
@@ -257,7 +257,7 @@ class AddSub(AbstractOperation):
@@ -257,7 +257,7 @@ class AddSub(AbstractOperation):
return a + b if self.is_add else a - b
return a + b if self.is_add else a - b
@property
@property
def is_add(self) -> Number:
def is_add(self) -> Num:
"""Get if operation is add."""
"""Get if operation is add."""
return self.param("is_add")
return self.param("is_add")
@@ -582,7 +582,7 @@ class ConstantMultiplication(AbstractOperation):
@@ -582,7 +582,7 @@ class ConstantMultiplication(AbstractOperation):
def __init__(
def __init__(
self,
self,
value: Number = 0,
value: Num = 0,
src0: Optional[SignalSourceProvider] = None,
src0: Optional[SignalSourceProvider] = None,
name: Name = Name(""),
name: Name = Name(""),
latency: Optional[int] = None,
latency: Optional[int] = None,
@@ -610,12 +610,12 @@ class ConstantMultiplication(AbstractOperation):
@@ -610,12 +610,12 @@ class ConstantMultiplication(AbstractOperation):
return a * self.param("value")
return a * self.param("value")
@property
@property
def value(self) -> Number:
def value(self) -> Num:
"""Get the constant value of this operation."""
"""Get the constant value of this operation."""
return self.param("value")
return self.param("value")
@value.setter
@value.setter
def value(self, value: Number) -> None:
def value(self, value: Num) -> None:
"""Set the constant value of this operation."""
"""Set the constant value of this operation."""
self.set_param("value", value)
self.set_param("value", value)
@@ -714,7 +714,7 @@ class SymmetricTwoportAdaptor(AbstractOperation):
@@ -714,7 +714,7 @@ class SymmetricTwoportAdaptor(AbstractOperation):
def __init__(
def __init__(
self,
self,
value: Number = 0,
value: Num = 0,
src0: Optional[SignalSourceProvider] = None,
src0: Optional[SignalSourceProvider] = None,
src1: Optional[SignalSourceProvider] = None,
src1: Optional[SignalSourceProvider] = None,
name: Name = Name(""),
name: Name = Name(""),
@@ -743,12 +743,12 @@ class SymmetricTwoportAdaptor(AbstractOperation):
@@ -743,12 +743,12 @@ class SymmetricTwoportAdaptor(AbstractOperation):
return b + tmp, a + tmp
return b + tmp, a + tmp
@property
@property
def value(self) -> Number:
def value(self) -> Num:
"""Get the constant value of this operation."""
"""Get the constant value of this operation."""
return self.param("value")
return self.param("value")
@value.setter
@value.setter
def value(self, value: Number) -> None:
def value(self, value: Num) -> None:
"""Set the constant value of this operation."""
"""Set the constant value of this operation."""
self.set_param("value", value)
self.set_param("value", value)
Loading