Skip to content
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
# -------------------------------------------
# Module containing Stim noise-dresser factories for measurement operations.
# Module containing Stim noise-dresser factories for additive pauli noise.
# -------------------------------------------
from typing import List, Tuple, Iterator
import numpy as np
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,13 @@ class StateKey(Enum):
STATE_1 = 1
STATE_2 = 2

# region Class Methods
def __lt__(self, other): # Add comparison for sorting if needed
if self.__class__ is other.__class__:
return self.value < other.value
return NotImplemented
# endregion


class IStabilizerIndexingKernel(IIndexingKernel, metaclass=ABCMeta):
"""
Expand Down
6 changes: 3 additions & 3 deletions src/qce_circuit/structure/circuit_operations.py
Original file line number Diff line number Diff line change
Expand Up @@ -1048,7 +1048,7 @@ class VirtualOptional(ICircuitOperation):
Data class, containing single-qubit operation.
Acts as a visualization wrapper.
"""
operation: SingleQubitOperation
operation: ICircuitOperation

# region Interface Properties
@property
Expand All @@ -1064,12 +1064,12 @@ def nr_of_repetitions(self) -> int:
@property
def relation_link(self) -> IRelationLink[ICircuitOperation]:
""":return: Description of relation to other circuit node."""
return self.operation.relation
return self.operation.relation_link

@relation_link.setter
def relation_link(self, link: IRelationLink[ICircuitOperation]):
""":sets: Description of relation to other circuit node."""
self.operation.relation = link
self.operation.relation_link = link

@property
def start_time(self) -> float:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -199,22 +199,23 @@ def get_transform_constructor(self) -> TransformConstructor:
)

def get_operation_draw_components(self) -> List[IDrawComponent]:
minimalist: bool = True
individual_component_factory = DrawComponentFactoryManager(
default_factory=DefaultFactory(),
factory_lookup={
CPhase: TwoQubitBlockFactory(),
DispersiveMeasure: MeasureFactory(),
Reset: ResetFactory(),
Wait: WaitFactory(),
Rx180: Rx180Factory(),
Rx90: Rx90Factory(),
Rxm90: Rxm90Factory(),
Rx180: Rx180Factory(minimalist=minimalist),
Rx90: Rx90Factory(minimalist=minimalist),
Rxm90: Rxm90Factory(minimalist=minimalist),
RxTheta: RxThetaFactory(),
Ry180: Ry180Factory(),
Ry90: Ry90Factory(),
Rym90: Rym90Factory(),
Ry180: Ry180Factory(minimalist=minimalist),
Ry90: Ry90Factory(minimalist=minimalist),
Rym90: Rym90Factory(minimalist=minimalist),
RyTheta: RyThetaFactory(),
Rx180ef: Rx180efFactory(),
Rx180ef: Rx180efFactory(minimalist=minimalist),
Rphi90: Rphi90Factory(),
VirtualPhase: ZPhaseFactory(),
Identity: IdentityFactory(),
Expand Down Expand Up @@ -338,7 +339,7 @@ def construct_visual_description(circuit: IDeclarativeCircuit, custom_channel_or
end_time = operation.end_time

return VisualCircuitDescription(
channel_width=end_time + 1.0,
channel_width=end_time,
channel_height=1.0,
channel_indices=channel_indices,
channel_label_map=custom_channel_map,
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ class HorizontalVariableIndicator(IRectTransformComponent, IDrawComponent):
width: float
height: float
alignment: TransformAlignment = field(default=TransformAlignment.MID_LEFT)
style_settings: IndicatorStyleSettings = field(default=StyleManager.read_config().indicator_style)
style_settings: IndicatorStyleSettings = field(default_factory=lambda: StyleManager.read_config().indicator_style)
text_string: str = field(default=r'$\mathtt{{\delta}}$')

# region Interface Properties
Expand Down Expand Up @@ -140,7 +140,7 @@ class RoundedRectangleHighlight(IRectTransformComponent, IDrawComponent):
width: float
height: float
alignment: TransformAlignment = field(default=TransformAlignment.MID_LEFT)
style_settings: HighlightStyleSettings = field(default=StyleManager.read_config().highlight_style)
style_settings: HighlightStyleSettings = field(default_factory=lambda: StyleManager.read_config().highlight_style)
text_string: str = field(default='x1')

# region Interface Properties
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -74,15 +74,20 @@ class ChannelHeader(IRectTransformComponent, IDrawComponent):
height: ILengthStrategy
channel_name: str
state_description: str
style_settings: ChannelStyleSettings = field(default=StyleManager.read_config().channel_style)
style_settings: ChannelStyleSettings = field(default_factory=lambda: StyleManager.read_config().channel_style)

# region Interface Properties
@property
def rectilinear_transform(self) -> IRectTransform:
""":return: 'Hard' rectilinear transform boundary. Should be treated as 'personal zone'."""
width: float = 0.0
if self.style_settings.enable_label_description:
width += self.channel_name_width + self.divider_width
if self.style_settings.enable_state_description:
width += self.state_description_width + self.divider_width
return RectTransform(
_pivot_strategy=DynamicPivot(lambda: self.pivot),
_width_strategy=DynamicLength(lambda: self.channel_name_width + self.state_description_width + 2 * self.divider_width),
_width_strategy=DynamicLength(lambda: width),
_height_strategy=self.height,
_parent_alignment=TransformAlignment.MID_RIGHT,
)
Expand All @@ -91,15 +96,15 @@ def rectilinear_transform(self) -> IRectTransform:
# region Class Properties
@property
def divider_width(self) -> float:
return 0.4
return self.style_settings.divider_width

@property
def channel_name_width(self) -> float:
return estimate_latex_length(latex_str=self.channel_name, font_size=self.style_settings.font_size)

@property
def state_description_width(self) -> float:
return 0.7
return self.style_settings.state_description_width

@property
def channel_name_pivot(self) -> Vec2D:
Expand Down Expand Up @@ -129,31 +134,35 @@ def right_divider(self) -> Line2D:
# region Interface Methods
def draw(self, axes: plt.Axes) -> plt.Axes:
"""Method used for drawing component on Axes."""
axes.text(
x=self.channel_name_pivot.x,
y=self.channel_name_pivot.y,
s=self.channel_name,
fontsize=self.style_settings.font_size,
color=self.style_settings.text_color,
ha='left',
va='center',
)
axes.text(
x=self.state_description_pivot.x,
y=self.state_description_pivot.y,
s=self.state_description,
fontsize=self.style_settings.font_size,
color=self.style_settings.text_color,
ha='center',
va='center',
)
axes.plot(
[self.center_divider.start.x, self.center_divider.end.x],
[self.center_divider.start.y, self.center_divider.end.y],
linestyle='-',
linewidth=self.style_settings.line_width,
color=self.style_settings.line_color,
)
if self.style_settings.enable_label_description:
axes.text(
x=self.channel_name_pivot.x,
y=self.channel_name_pivot.y,
s=self.channel_name,
fontsize=self.style_settings.font_size,
color=self.style_settings.text_color,
ha='right',
va='center',
)
axes.plot(
[self.center_divider.start.x, self.center_divider.end.x],
[self.center_divider.start.y, self.center_divider.end.y],
linestyle='-',
linewidth=self.style_settings.line_width,
color=self.style_settings.line_color,
)

if self.style_settings.enable_state_description:
axes.text(
x=self.state_description_pivot.x,
y=self.state_description_pivot.y,
s=self.state_description,
fontsize=self.style_settings.font_size,
color=self.style_settings.text_color,
ha='center',
va='center',
)

axes.plot(
[self.right_divider.start.x, self.right_divider.end.x],
[self.right_divider.start.y, self.right_divider.end.y],
Expand All @@ -174,7 +183,7 @@ class ChannelBar(IRectTransformComponent, IDrawComponent):
width: float
height: float
alignment: TransformAlignment = field(init=False, default=TransformAlignment.MID_LEFT)
style_settings: ChannelStyleSettings = field(default=StyleManager.read_config().channel_style)
style_settings: ChannelStyleSettings = field(default_factory=lambda: StyleManager.read_config().channel_style)

# region Class Properties
@property
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
# -------------------------------------------
# Module containing functionality for constructing draw components from operation class types.
# -------------------------------------------
from dataclasses import dataclass, field
from typing import List
from qce_circuit.structure.intrf_circuit_operation import (
ICircuitOperation,
Expand Down Expand Up @@ -109,7 +110,9 @@ def construct(self, operation: Reset, transform_constructor: ITransformConstruct
# endregion


@dataclass(frozen=True)
class Rx180Factory(IOperationDrawComponentFactory[Rx180, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Rx180, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -118,6 +121,14 @@ def construct(self, operation: Rx180, transform_constructor: ITransformConstruct
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"{RotationAxis.X.value}",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand All @@ -128,7 +139,9 @@ def construct(self, operation: Rx180, transform_constructor: ITransformConstruct
# endregion


@dataclass(frozen=True)
class Rx90Factory(IOperationDrawComponentFactory[Rx90, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Rx90, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -137,6 +150,14 @@ def construct(self, operation: Rx90, transform_constructor: ITransformConstructo
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"+{RotationAxis.X.value}/2",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand All @@ -147,7 +168,9 @@ def construct(self, operation: Rx90, transform_constructor: ITransformConstructo
# endregion


@dataclass(frozen=True)
class Rxm90Factory(IOperationDrawComponentFactory[Rxm90, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Rxm90, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -156,6 +179,14 @@ def construct(self, operation: Rxm90, transform_constructor: ITransformConstruct
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"-{RotationAxis.X.value}/2",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand Down Expand Up @@ -185,7 +216,9 @@ def construct(self, operation: RxTheta, transform_constructor: ITransformConstru
# endregion


@dataclass(frozen=True)
class Ry180Factory(IOperationDrawComponentFactory[Ry180, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Ry180, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -194,6 +227,14 @@ def construct(self, operation: Ry180, transform_constructor: ITransformConstruct
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"{RotationAxis.Y.value}",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand All @@ -204,7 +245,9 @@ def construct(self, operation: Ry180, transform_constructor: ITransformConstruct
# endregion


@dataclass(frozen=True)
class Ry90Factory(IOperationDrawComponentFactory[Ry90, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Ry90, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -213,6 +256,14 @@ def construct(self, operation: Ry90, transform_constructor: ITransformConstructo
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"+{RotationAxis.Y.value}/2",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand All @@ -223,7 +274,9 @@ def construct(self, operation: Ry90, transform_constructor: ITransformConstructo
# endregion


@dataclass(frozen=True)
class Rym90Factory(IOperationDrawComponentFactory[Rym90, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Rym90, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -232,6 +285,14 @@ def construct(self, operation: Rym90, transform_constructor: ITransformConstruct
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"-{RotationAxis.Y.value}/2",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand Down Expand Up @@ -261,7 +322,9 @@ def construct(self, operation: RyTheta, transform_constructor: ITransformConstru
# endregion


@dataclass(frozen=True)
class Rx180efFactory(IOperationDrawComponentFactory[Rx180, IDrawComponent]):
minimalist: bool = field(default=False)

# region Interface Methods
def construct(self, operation: Rx180, transform_constructor: ITransformConstructor) -> IDrawComponent:
Expand All @@ -270,6 +333,14 @@ def construct(self, operation: Rx180, transform_constructor: ITransformConstruct
identifier=operation.channel_identifiers[0],
time_component=operation,
)
if self.minimalist:
return BlockHeaderBody(
pivot=transform.pivot,
height=transform.height,
alignment=transform.parent_alignment,
header_text=f"${RotationAxis.X.value}_{{12}}$",
)

return BlockRotation(
pivot=transform.pivot,
height=transform.height,
Expand Down
Loading