Skip to content

Circuit

Circuit

Bases: Block

The Circuit object is a symbolic representation of a quantum circuit for qubits, qudits, or for an infinite-dimensional Fock space. The circuit is composed of a sequence of quantum operators on wires which define the evolution of the quantum

Attributes:

Name Type Description
ops dict[Union[str, int], AbstractOp]

A dictionary of ops (dictionary value) with an assigned label (dictionary key).

Example
circuit = Circuit(backend='pure')
circuit.add(DiscreteVariableState(wires=(0,)))
circuit.add(HGate(wires=(0,)))
Source code in src/squint/circuit.py
class Circuit(Block):
    r"""
    The `Circuit` object is a symbolic representation of a quantum circuit for qubits, qudits, or for an infinite-dimensional Fock space.
    The circuit is composed of a sequence of quantum operators on `wires` which define the evolution of the quantum

    Attributes:
        ops (dict[Union[str, int], AbstractOp]): A dictionary of ops (dictionary value) with an assigned label (dictionary key).

    Example:
        ```python
        circuit = Circuit(backend='pure')
        circuit.add(DiscreteVariableState(wires=(0,)))
        circuit.add(HGate(wires=(0,)))
        ```
    """

    @beartype
    @classmethod
    def from_block(
        cls,
        block: Block,
    ):
        """Promote a Block to a Circuit"""
        self = cls()
        self.ops = block.ops
        return self

from_block(block: Block) classmethod

Promote a Block to a Circuit

Source code in src/squint/circuit.py
@beartype
@classmethod
def from_block(
    cls,
    block: Block,
):
    """Promote a Block to a Circuit"""
    self = cls()
    self.ops = block.ops
    return self