Skip to content

controlled_gate

ControlledGateSemantic

Bases: GateSemantic

Source code in opensquirrel/ir/semantics/controlled_gate.py
class ControlledGateSemantic(GateSemantic):
    def __init__(self, target_bsr: BlochSphereRotation) -> None:
        self.target_bsr = target_bsr

    def accept(self, visitor: IRVisitor) -> Any:
        """Accepts visitor and processes this IR node."""
        return visitor.visit_controlled_gate_semantic(self)

    def is_identity(self) -> bool:
        """Checks if the controlled gate semantic represents an identity operation.

        Returns:
            True if the controlled gate semantic represents an identity operation, False otherwise.

        """
        return self.target_bsr.is_identity()

    def __repr__(self) -> str:
        return f"ControlledGateSemantic(target_bsr={self.target_bsr})"

accept

accept(visitor: IRVisitor) -> Any

Accepts visitor and processes this IR node.

Source code in opensquirrel/ir/semantics/controlled_gate.py
def accept(self, visitor: IRVisitor) -> Any:
    """Accepts visitor and processes this IR node."""
    return visitor.visit_controlled_gate_semantic(self)

is_identity

is_identity() -> bool

Checks if the controlled gate semantic represents an identity operation.

Returns:

Type Description
bool

True if the controlled gate semantic represents an identity operation, False otherwise.

Source code in opensquirrel/ir/semantics/controlled_gate.py
def is_identity(self) -> bool:
    """Checks if the controlled gate semantic represents an identity operation.

    Returns:
        True if the controlled gate semantic represents an identity operation, False otherwise.

    """
    return self.target_bsr.is_identity()