pub struct Calibrations {
pub calibrations: CalibrationSet<CalibrationDefinition>,
pub measure_calibrations: CalibrationSet<MeasureCalibrationDefinition>,
}Expand description
A collection of Quil calibrations (DEFCAL instructions) with utility methods.
This exposes the semantics similar to CalibrationSet to Python users,
so see the documentation there for more information.
Fields§
§calibrations: CalibrationSet<CalibrationDefinition>§measure_calibrations: CalibrationSet<MeasureCalibrationDefinition>Implementations§
Source§impl Calibrations
impl Calibrations
Sourcepub fn insert_calibration(
&mut self,
calibration: CalibrationDefinition,
) -> Option<CalibrationDefinition>
pub fn insert_calibration( &mut self, calibration: CalibrationDefinition, ) -> Option<CalibrationDefinition>
Insert a CalibrationDefinition into the set.
If a calibration with the same signature already exists in the set, it will be replaced and the old calibration will be returned.
Sourcepub fn insert_measurement_calibration(
&mut self,
calibration: MeasureCalibrationDefinition,
) -> Option<MeasureCalibrationDefinition>
pub fn insert_measurement_calibration( &mut self, calibration: MeasureCalibrationDefinition, ) -> Option<MeasureCalibrationDefinition>
Insert a MeasureCalibrationDefinition into the set.
If a calibration with the same signature already exists in the set, it will be replaced and the old calibration will be returned.
Sourcepub fn extend(&mut self, other: Calibrations)
pub fn extend(&mut self, other: Calibrations)
Append another CalibrationSet onto this one.
Calibrations with conflicting [CalibrationSignature]s are overwritten by the ones in the
given set.
Sourcepub fn to_instructions(&self) -> Vec<Instruction>
pub fn to_instructions(&self) -> Vec<Instruction>
Return the Quil instructions which describe the contained calibrations.
Source§impl Calibrations
impl Calibrations
Sourcepub fn iter_calibrations(
&self,
) -> impl DoubleEndedIterator<Item = &CalibrationDefinition> + FusedIterator
pub fn iter_calibrations( &self, ) -> impl DoubleEndedIterator<Item = &CalibrationDefinition> + FusedIterator
Iterate over all CalibrationDefinitions in the set
Sourcepub fn iter_measure_calibrations(
&self,
) -> impl DoubleEndedIterator<Item = &MeasureCalibrationDefinition> + FusedIterator
pub fn iter_measure_calibrations( &self, ) -> impl DoubleEndedIterator<Item = &MeasureCalibrationDefinition> + FusedIterator
Iterate over all MeasureCalibrationDefinitions calibrations in the set
Sourcepub fn expand(
&self,
instruction: &Instruction,
previous_calibrations: &[Instruction],
) -> Result<Option<Vec<Instruction>>, ProgramError>
pub fn expand( &self, instruction: &Instruction, previous_calibrations: &[Instruction], ) -> Result<Option<Vec<Instruction>>, ProgramError>
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 expands into itself.
Return only the expanded instructions; for more information about the expansion process,
see Self::expand_with_detail.
Sourcepub fn expand_with_detail(
&self,
instruction: &Instruction,
previous_calibrations: &[Instruction],
) -> Result<Option<CalibrationExpansionOutput>, ProgramError>
pub fn expand_with_detail( &self, instruction: &Instruction, previous_calibrations: &[Instruction], ) -> Result<Option<CalibrationExpansionOutput>, ProgramError>
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 expands into itself.
Also return information about the expansion.
Sourcepub fn get_match_for_measurement(
&self,
measurement: &Measurement,
) -> Option<&MeasureCalibrationDefinition>
pub fn get_match_for_measurement( &self, measurement: &Measurement, ) -> Option<&MeasureCalibrationDefinition>
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:
- Match fixed qubit.
- Match variable qubit.
- Match no qubit.
In the case of multiple calibrations with equal precedence, the last one wins.
Sourcepub fn get_match_for_gate(&self, gate: &Gate) -> Option<&CalibrationDefinition>
pub fn get_match_for_gate(&self, gate: &Gate) -> Option<&CalibrationDefinition>
Return the final calibration which matches the gate per the QuilT specification:
A calibration matches a gate if:
- It has the same name
- It has the same modifiers
- It has the same qubit count (any mix of fixed & variable)
- It has the same parameter count (both specified and unspecified)
- All fixed qubits in the calibration definition match those in the gate
- All specified parameters in the calibration definition match those in the gate
Sourcepub fn into_instructions(self) -> Vec<Instruction>
pub fn into_instructions(self) -> Vec<Instruction>
Return the Quil instructions which describe the contained calibrations, consuming the CalibrationSet
Trait Implementations§
Source§impl Clone for Calibrations
impl Clone for Calibrations
Source§fn clone(&self) -> Calibrations
fn clone(&self) -> Calibrations
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreSource§impl Debug for Calibrations
impl Debug for Calibrations
Source§impl Default for Calibrations
impl Default for Calibrations
Source§fn default() -> Calibrations
fn default() -> Calibrations
Source§impl PartialEq for Calibrations
impl PartialEq for Calibrations
impl StructuralPartialEq for Calibrations
Auto Trait Implementations§
impl Freeze for Calibrations
impl RefUnwindSafe for Calibrations
impl Send for Calibrations
impl Sync for Calibrations
impl Unpin for Calibrations
impl UnwindSafe for Calibrations
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SPwhere
SS: SubsetOf<SP>,
Source§fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
self from the equivalent element of its
superset. Read moreSource§fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
self is actually part of its subset T (and can be converted to it).Source§fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
self.to_subset but without any property checks. Always succeeds.Source§fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
self to the equivalent element of its superset.