Skip to content

Commit 07c11d5

Browse files
erichulburdasaites
authored andcommitted
feat: defgate as sequence
1 parent 5f44691 commit 07c11d5

File tree

17 files changed

+3247
-512
lines changed

17 files changed

+3247
-512
lines changed

quil-rs/python/quil/instructions.pyi

Lines changed: 80 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -419,6 +419,40 @@ class Declaration:
419419
def to_quil(self) -> builtins.str: ...
420420
def to_quil_or_debug(self) -> builtins.str: ...
421421

422+
class DefGateSequence:
423+
r"""
424+
A sequence of gates that make up a defined gate (i.e. with `DEFGATE ... AS SEQUENCE`).
425+
"""
426+
@property
427+
def gates(self) -> builtins.list[Gate]:
428+
r"""
429+
The list of `Gate` objects that make up the sequence.
430+
"""
431+
@property
432+
def qubits(self) -> builtins.list[builtins.str]:
433+
r"""
434+
The list of qubit variable names in the gate signature.
435+
"""
436+
def __eq__(self, other:builtins.object) -> builtins.bool: ...
437+
def __getnewargs__(self) -> tuple[builtins.list[builtins.str], builtins.list[Gate]]: ...
438+
def __hash__(self) -> builtins.int: ...
439+
def __new__(cls, qubits:typing.Sequence[builtins.str], gates:typing.Sequence[Gate]) -> DefGateSequence:
440+
r"""
441+
Creates a new `DefGateSequence` with the given qubits and gates.
442+
443+
`qubits` should be a list of qubit names that the gates in the sequence will act on.
444+
`gates` should be a list of `Gate` objects that make up the sequence.
445+
Each gate must reference qubits in the `qubits` list by name.
446+
They may not specify a fixed qubit.
447+
"""
448+
def __repr__(self) -> builtins.str: ...
449+
450+
class DefGateSequenceError(InstructionError):
451+
r"""
452+
Errors that can occur when initializing a sequence gate definition.
453+
"""
454+
...
455+
422456
class Delay:
423457
@property
424458
def duration(self) -> Expression: ...
@@ -671,6 +705,8 @@ class GateDefinition:
671705
@property
672706
def parameters(self) -> builtins.list[builtins.str]: ...
673707
@property
708+
def signature(self) -> OwnedGateSignature: ...
709+
@property
674710
def specification(self) -> GateSpecification: ...
675711
def __eq__(self, other:builtins.object) -> builtins.bool: ...
676712
def __getnewargs__(self) -> tuple[builtins.str, builtins.list[builtins.str], GateSpecification]: ...
@@ -690,7 +726,7 @@ class GateSpecification:
690726
r"""
691727
An enum representing a the specification of a [`GateDefinition`] for a given [`GateType`]
692728
"""
693-
def __getnewargs__(self) -> tuple[list[list[Expression]] | list[int] | PauliSum]: ...
729+
def __getnewargs__(self) -> tuple[list[list[Expression]] | list[int] | PauliSum | DefGateSequence]: ...
694730
def __repr__(self) -> builtins.str: ...
695731
def to_quil(self) -> builtins.str: ...
696732
def to_quil_or_debug(self) -> builtins.str: ...
@@ -728,6 +764,17 @@ class GateSpecification:
728764
def __len__(self) -> builtins.int: ...
729765
def __new__(cls, _0:typing.Sequence[builtins.int]) -> GateSpecification.Permutation: ...
730766

767+
class Sequence(GateSpecification):
768+
r"""
769+
A sequence of gates.
770+
"""
771+
__match_args__ = ("_0",)
772+
@property
773+
def _0(self) -> DefGateSequence: ...
774+
def __getitem__(self, key:builtins.int) -> typing.Any: ...
775+
def __len__(self) -> builtins.int: ...
776+
def __new__(cls, _0:DefGateSequence) -> GateSpecification.Sequence: ...
777+
731778

732779
class Include:
733780
@property
@@ -1325,6 +1372,25 @@ class Offset:
13251372
def to_quil(self) -> builtins.str: ...
13261373
def to_quil_or_debug(self) -> builtins.str: ...
13271374

1375+
class OwnedGateSignature:
1376+
r"""
1377+
A signature for a gate definition; this does not include the gate definition content.
1378+
To get a signature from a definition, use `GateDefinition.signature`.
1379+
"""
1380+
@property
1381+
def gate_parameters(self) -> builtins.list[builtins.str]: ...
1382+
@property
1383+
def gate_type(self) -> GateType: ...
1384+
@property
1385+
def name(self) -> builtins.str: ...
1386+
@property
1387+
def qubit_parameters(self) -> builtins.list[builtins.str]: ...
1388+
def __eq__(self, other:builtins.object) -> builtins.bool: ...
1389+
def __getnewargs__(self) -> tuple[builtins.str, builtins.list[builtins.str], builtins.list[builtins.str], GateType]: ...
1390+
def __hash__(self) -> builtins.int: ...
1391+
def __new__(cls, name:builtins.str, gate_parameters:typing.Sequence[builtins.str], qubit_parameters:typing.Sequence[builtins.str], gate_type:GateType) -> OwnedGateSignature: ...
1392+
def __repr__(self) -> builtins.str: ...
1393+
13281394
class ParseInstructionError(InstructionError):
13291395
r"""
13301396
Errors that may occur while parsing an ``Instruction``.
@@ -1748,6 +1814,19 @@ class GateModifier(Enum):
17481814
def to_quil(self) -> builtins.str: ...
17491815
def to_quil_or_debug(self) -> builtins.str: ...
17501816

1817+
class GateType(Enum):
1818+
r"""
1819+
The type of a [`GateDefinition`] used within the [`GateSignature`].
1820+
"""
1821+
MATRIX = ...
1822+
PERMUTATION = ...
1823+
PAULI_SUM = ...
1824+
SEQUENCE = ...
1825+
1826+
def __repr__(self) -> builtins.str: ...
1827+
def to_quil(self) -> builtins.str: ...
1828+
def to_quil_or_debug(self) -> builtins.str: ...
1829+
17511830
class PauliGate(Enum):
17521831
I = ...
17531832
X = ...

0 commit comments

Comments
 (0)