Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
319 changes: 239 additions & 80 deletions quil-rs/python/quil/_quil/instructions/__init__.pyi

Large diffs are not rendered by default.

85 changes: 36 additions & 49 deletions quil-rs/python/quil/_quil/program/__init__.pyi
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,6 @@ __all__ = [
"BasicBlockScheduleError",
"CalibrationExpansion",
"CalibrationSet",
"CalibrationSource",
"ComputedScheduleError",
"ControlFlowGraph",
"FrameSet",
Expand Down Expand Up @@ -81,7 +80,7 @@ class CalibrationExpansion:
Details about the expansion of a calibration.
"""
@property
def calibration_used(self) -> CalibrationSource:
def calibration_used(self) -> instructions.CalibrationIdentifier:
r"""
The calibration used to expand the instruction.
"""
Expand Down Expand Up @@ -111,27 +110,32 @@ class CalibrationSet:
so see the documentation there for more information.
"""
@property
def calibrations(self) -> builtins.list[instructions.CalibrationDefinition]:
def gate_calibrations(self) -> builtins.list[instructions.GateCalibrationDefinition]:
r"""
Return a list of all [`CalibrationDefinition`]s in the set.
Return a list of all [`GateCalibrationDefinition`]s in the set.
"""
@property
def measure_calibrations(self) -> builtins.list[instructions.MeasureCalibrationDefinition]:
r"""
Return a list of all [`MeasureCalibrationDefinition`]s in the set.
"""
@property
def reset_calibrations(self) -> builtins.list[instructions.ResetCalibrationDefinition]:
r"""
Return a list of all [`ResetCalibrationDefinition`]s in the set.
"""
def __eq__(self, other: builtins.object, /) -> builtins.bool: ...
def __len__(self) -> builtins.int:
r"""
Return the count of contained calibrations.
"""
def __new__(cls, calibrations: typing.Sequence[instructions.CalibrationDefinition], measure_calibrations: typing.Sequence[instructions.MeasureCalibrationDefinition]) -> CalibrationSet: ...
def __new__(cls, gate_calibrations: typing.Sequence[instructions.GateCalibrationDefinition], measure_calibrations: typing.Sequence[instructions.MeasureCalibrationDefinition], reset_calibrations: typing.Sequence[instructions.ResetCalibrationDefinition]) -> CalibrationSet: ...
def __repr__(self) -> builtins.str:
r"""
Implements `__repr__` for Python in terms of the Rust
[`Debug`](std::fmt::Debug) implementation.
"""
def expand(self, instruction: instructions.Instruction, previous_calibrations: typing.Sequence[instructions.Instruction]) -> typing.Optional[builtins.list[instructions.Instruction]]:
def expand(self, instruction: instructions.Instruction, previous_calibrations: typing.Sequence[instructions.Instruction], qubits_available: builtins.set[instructions.Qubit]) -> typing.Optional[builtins.list[instructions.Instruction]]:
r"""
Given an instruction, return the instructions to which it is expanded if there is a match.
Recursively calibrate instructions, returning an error if a calibration directly or indirectly
Expand All @@ -147,9 +151,9 @@ class CalibrationSet:
Calibrations with conflicting [signatures][crate::instruction::CalibrationSignature] are
overwritten by the ones in the given set.
"""
def get_match_for_gate(self, gate: instructions.Gate) -> typing.Optional[instructions.CalibrationDefinition]:
def get_match_for_gate(self, gate: instructions.Gate) -> typing.Optional[instructions.GateCalibrationDefinition]:
r"""
Return the final calibration which matches the gate per the `QuilT` specification:
Return the final calibration which matches the gate per the Quil-T specification:

A calibration matches a gate if:
1. It has the same name
Expand All @@ -161,7 +165,7 @@ class CalibrationSet:
"""
def get_match_for_measurement(self, measurement: instructions.Measurement) -> typing.Optional[instructions.MeasureCalibrationDefinition]:
r"""
Returns the last-specified ``MeasureCalibrationDefinition`` that matches the target
Returns the last-specified [`MeasureCalibrationDefinition`] that matches the target
qubit (if any), or otherwise the last-specified one that specified no qubit.

If multiple calibrations match the measurement, the precedence is as follows:
Expand All @@ -172,9 +176,21 @@ class CalibrationSet:

In the case of multiple calibrations with equal precedence, the last one wins.
"""
def insert_calibration(self, calibration: instructions.CalibrationDefinition) -> typing.Optional[instructions.CalibrationDefinition]:
def get_match_for_reset(self, reset: instructions.Reset) -> typing.Optional[instructions.ResetCalibrationDefinition]:
r"""
Insert a [`CalibrationDefinition`] into the set.
Returns the last-specified [`ResetCalibrationDefinition`] that matches the target
qubit (if any), or otherwise the last-specified one that specified no qubit.

If multiple calibrations match the measurement, the precedence is as follows:

1. Match fixed qubit.
2. Match variable qubit.

In the case of multiple calibrations with equal precedence, the last one wins.
"""
def insert_gate_calibration(self, calibration: instructions.GateCalibrationDefinition) -> typing.Optional[instructions.GateCalibrationDefinition]:
r"""
Insert a [`GateCalibrationDefinition`] into the set.

If a calibration with the same [signature][crate::instruction::CalibrationSignature] already
exists in the set, it will be replaced and the old calibration will be returned.
Expand All @@ -183,6 +199,13 @@ class CalibrationSet:
r"""
Insert a [`MeasureCalibrationDefinition`] into the set.

If a calibration with the same [signature][crate::instruction::CalibrationSignature] already
exists in the set, it will be replaced and the old calibration will be returned.
"""
def insert_reset_calibration(self, calibration: instructions.ResetCalibrationDefinition) -> typing.Optional[instructions.ResetCalibrationDefinition]:
r"""
Insert a [`ResetCalibrationDefinition`] into the set.

If a calibration with the same [signature][crate::instruction::CalibrationSignature] already
exists in the set, it will be replaced and the old calibration will be returned.
"""
Expand All @@ -195,42 +218,6 @@ class CalibrationSet:
Return the Quil instructions which describe the contained calibrations.
"""

class CalibrationSource:
r"""
The source of a calibration, either a [`CalibrationIdentifier`] or a
[`MeasureCalibrationIdentifier`].
"""
def __getnewargs__(self) -> builtins.tuple[_quil.instructions.CalibrationIdentifier | _quil.instructions.MeasureCalibrationIdentifier]: ...
def __repr__(self) -> builtins.str:
r"""
Implements `__repr__` for Python in terms of the Rust
[`Debug`](std::fmt::Debug) implementation.
"""
@typing.final
class Calibration(CalibrationSource):
r"""
Describes a `DEFCAL` instruction
"""
__match_args__ = ("_0",)
@property
def _0(self) -> instructions.CalibrationIdentifier: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...
def __len__(self) -> builtins.int: ...
def __new__(cls, _0: instructions.CalibrationIdentifier) -> CalibrationSource.Calibration: ...

@typing.final
class MeasureCalibration(CalibrationSource):
r"""
Describes a `DEFCAL MEASURE` instruction
"""
__match_args__ = ("_0",)
@property
def _0(self) -> instructions.MeasureCalibrationIdentifier: ...
def __getitem__(self, key: builtins.int, /) -> typing.Any: ...
def __len__(self) -> builtins.int: ...
def __new__(cls, _0: instructions.MeasureCalibrationIdentifier) -> CalibrationSource.MeasureCalibration: ...


class ComputedScheduleError(ProgramError):
r"""
Error raised if the computed schedule is invalid.
Expand Down Expand Up @@ -313,9 +300,9 @@ class InstructionSourceMap:
a calibration or a sequence gate definition.
"""
def entries(self) -> builtins.list[InstructionSourceMapEntry]: ...
def list_sources_for_calibration_used(self, calibration_used: CalibrationSource) -> builtins.list[builtins.int]:
def list_sources_for_calibration_used(self, calibration_used: instructions.CalibrationIdentifier) -> builtins.list[builtins.int]:
r"""
Given a particular calibration (`DEFCAL` or `DEFCAL MEASURE`), =
Given a particular calibration (`DEFCAL`, `DEFCAL MEASURE`, or `DEFCAL RESET`),
return the locations in the source which were expanded using that calibration.

This is `O(n)` where `n` is the number of first-level calibration expansions performed,
Expand Down
6 changes: 5 additions & 1 deletion quil-rs/python/quil/instructions/__init__.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: F401

from quil._quil.instructions import Arithmetic, ArithmeticOperand, ArithmeticOperator, AttributeValue, BinaryLogic, BinaryOperand, BinaryOperator, CalibrationDefinition, CalibrationIdentifier, Call, CallArgument, CallError, Capture, CircuitDefinition, Comparison, ComparisonOperand, ComparisonOperator, Convert, Declaration, DefGateSequence, DefGateSequenceError, Delay, Exchange, ExternError, ExternParameter, ExternParameterType, ExternSignature, Fence, FrameDefinition, FrameIdentifier, Gate, GateDefinition, GateError, GateModifier, GateSignature, GateSpecification, GateType, Include, Instruction, InstructionError, Jump, JumpUnless, JumpWhen, Label, Load, MeasureCalibrationDefinition, MeasureCalibrationIdentifier, Measurement, MemoryReference, Move, Offset, ParseInstructionError, ParseMemoryReferenceError, PauliGate, PauliSum, PauliTerm, Pragma, PragmaArgument, Pulse, Qubit, QubitPlaceholder, RawCapture, Reset, ScalarType, SetFrequency, SetPhase, SetScale, Sharing, ShiftFrequency, ShiftPhase, Store, SwapPhases, Target, TargetPlaceholder, UnaryLogic, UnaryOperator, Vector, Waveform, WaveformDefinition, WaveformInvocation
from quil._quil.instructions import Arithmetic, ArithmeticOperand, ArithmeticOperator, AttributeValue, BinaryLogic, BinaryOperand, BinaryOperator, CalibrationDefinition, CalibrationIdentifier, Call, CallArgument, CallError, Capture, CircuitDefinition, Comparison, ComparisonOperand, ComparisonOperator, Convert, Declaration, DefGateSequence, DefGateSequenceError, Delay, Exchange, ExternError, ExternParameter, ExternParameterType, ExternSignature, Fence, FrameDefinition, FrameIdentifier, Gate, GateCalibrationDefinition, GateCalibrationIdentifier, GateDefinition, GateError, GateModifier, GateSignature, GateSpecification, GateType, Include, Instruction, InstructionError, Jump, JumpUnless, JumpWhen, Label, Load, MeasureCalibrationDefinition, MeasureCalibrationIdentifier, Measurement, MemoryReference, Move, Offset, ParseInstructionError, ParseMemoryReferenceError, PauliGate, PauliSum, PauliTerm, Pragma, PragmaArgument, Pulse, Qubit, QubitPlaceholder, RawCapture, Reset, ResetCalibrationDefinition, ResetCalibrationIdentifier, ScalarType, SetFrequency, SetPhase, SetScale, Sharing, ShiftFrequency, ShiftPhase, Store, SwapPhases, Target, TargetPlaceholder, UnaryLogic, UnaryOperator, Vector, Waveform, WaveformDefinition, WaveformInvocation
__all__ = [
"Arithmetic",
"ArithmeticOperand",
Expand Down Expand Up @@ -34,6 +34,8 @@
"FrameDefinition",
"FrameIdentifier",
"Gate",
"GateCalibrationDefinition",
"GateCalibrationIdentifier",
"GateDefinition",
"GateError",
"GateModifier",
Expand Down Expand Up @@ -66,6 +68,8 @@
"QubitPlaceholder",
"RawCapture",
"Reset",
"ResetCalibrationDefinition",
"ResetCalibrationIdentifier",
"ScalarType",
"SetFrequency",
"SetPhase",
Expand Down
3 changes: 1 addition & 2 deletions quil-rs/python/quil/program/__init__.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
# This file is automatically generated by pyo3_stub_gen
# ruff: noqa: F401

from quil._quil.program import BasicBlock, BasicBlockScheduleError, CalibrationExpansion, CalibrationSet, CalibrationSource, ComputedScheduleError, ControlFlowGraph, FrameSet, InstructionSourceMap, InstructionSourceMapEntry, InstructionTarget, MemoryRegion, OwnedDefGateSequenceExpansion, Program, ProgramError, QubitGraphError, ScheduleSeconds, ScheduleSecondsItem, TimeSpanSeconds
from quil._quil.program import BasicBlock, BasicBlockScheduleError, CalibrationExpansion, CalibrationSet, ComputedScheduleError, ControlFlowGraph, FrameSet, InstructionSourceMap, InstructionSourceMapEntry, InstructionTarget, MemoryRegion, OwnedDefGateSequenceExpansion, Program, ProgramError, QubitGraphError, ScheduleSeconds, ScheduleSecondsItem, TimeSpanSeconds
__all__ = [
"BasicBlock",
"BasicBlockScheduleError",
"CalibrationExpansion",
"CalibrationSet",
"CalibrationSource",
"ComputedScheduleError",
"ControlFlowGraph",
"FrameSet",
Expand Down
Loading
Loading