Struct qoqo::QuantumProgramWrapper
source · [−]pub struct QuantumProgramWrapper {
pub internal: QuantumProgram,
}
Expand description
Represents a quantum program evaluating measurements based on a one or more free float parameters.
The main use of QuantumProgram is to contain a Measurements implementing [crate::measurements::Measure]
that measures expectation values or output registers of [crate::Circuit] quantum circuits that contain
symbolic parameters. Circuit with symbolic parameters can not be simulated or executed on real hardware.
The symbolic parameters need to be replaced with real floating point numbers first.
A QuantumProgram contains a list of the free parameters (input_parameter_names
) and can automatically
replace the parameters with its run
methods and return the result.
The QuantumProgram should correspond as closely as possible to a normal mulit-parameter function in classical computing that can be called with a set of parameters and returns a result. It is the intended way to interface between normal program code and roqoqo based quantum programs.
Fields
internal: QuantumProgram
Internal storage of roqoqo::QuantumProgram
Implementations
sourceimpl QuantumProgramWrapper
impl QuantumProgramWrapper
sourcepub fn new(
measurement: &PyAny,
input_parameter_names: Vec<String>
) -> PyResult<Self>
pub fn new(
measurement: &PyAny,
input_parameter_names: Vec<String>
) -> PyResult<Self>
Create a QuantumProgram.
Args: measurement: input_parameter_names (Liststr):
Returns: self: The new .
sourcepub fn measurement(&self) -> PyObject
pub fn measurement(&self) -> PyObject
Returns the measurement attribute of the QuantumProgram as Python object.
Returns: PyObject corresponding to the qoqo measurement type of the QuantumProgram, i.e. PauliZProduct, CheatedPauliZProduct, Cheated or ClassicalRegister.
sourcepub fn input_parameter_names(&self) -> Vec<String>
pub fn input_parameter_names(&self) -> Vec<String>
Returns the input_parameter_names attribute of the qoqo QuantumProgram.
Returns: List of input parameter names.
sourcepub fn run(
&self,
backend: Py<PyAny>,
parameters: Option<Vec<f64>>
) -> PyResult<Py<PyAny>>
pub fn run(
&self,
backend: Py<PyAny>,
parameters: Option<Vec<f64>>
) -> PyResult<Py<PyAny>>
Runs the QuantumProgram and returns expectation values.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters
listed in input_parameter_names
and returns expectation values.
Args:
backend (Backend): The backend the program is executed on.
parameters (Optional[List[float]): List of float parameters of the function call in order of input_parameter_names
sourcepub fn run_registers(
&self,
backend: Py<PyAny>,
parameters: Option<Vec<f64>>
) -> PyResult<Py<PyAny>>
pub fn run_registers(
&self,
backend: Py<PyAny>,
parameters: Option<Vec<f64>>
) -> PyResult<Py<PyAny>>
Runs the QuantumProgram and returns the classical registers of the quantum program.
Runs the quantum programm for a given set of parameters passed in the same order as the parameters
listed in input_parameter_names
and returns the classical register output.
The classical registers usually contain a record of measurement values for the repeated execution
of a [crate::Circuit] quantum circuit for real quantum hardware
or the readout of the statevector or the density matrix for simulators.
Args:
backend (Backend): The backend the program is executed on.
parameters (Optional[List[float]): List of float parameters of the function call in order of input_parameter_names
sourcepub fn __copy__(&self) -> QuantumProgramWrapper
pub fn __copy__(&self) -> QuantumProgramWrapper
Return a copy of the QuantumProgram (copy here produces a deepcopy).
Returns: QuantumProgram: A deep copy of self.
sourcepub fn __deepcopy__(&self, _memodict: Py<PyAny>) -> QuantumProgramWrapper
pub fn __deepcopy__(&self, _memodict: Py<PyAny>) -> QuantumProgramWrapper
Return a deep copy of the QuantumProgram.
Returns: QuantumProgram: A deep copy of self.
sourcepub fn to_bincode(&self) -> PyResult<Py<PyByteArray>>
pub fn to_bincode(&self) -> PyResult<Py<PyByteArray>>
sourcepub fn from_bincode(cls: &PyType, input: &PyAny) -> PyResult<Self>
pub fn from_bincode(cls: &PyType, input: &PyAny) -> PyResult<Self>
Convert the bincode representation of the QuantumProgram to a QuantumProgram using the bincode crate.
Args: input (ByteArray): The serialized QuantumProgram (in bincode form).
Returns: QuantumProgram: The deserialized QuantumProgram.
Raises: TypeError: Input cannot be converted to byte array. ValueError: Input cannot be deserialized to QuantumProgram.
Trait Implementations
sourceimpl Clone for QuantumProgramWrapper
impl Clone for QuantumProgramWrapper
sourcefn clone(&self) -> QuantumProgramWrapper
fn clone(&self) -> QuantumProgramWrapper
Returns a copy of the value. Read more
1.0.0 · sourcefn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from source
. Read more
sourceimpl Debug for QuantumProgramWrapper
impl Debug for QuantumProgramWrapper
sourceimpl<'de> Deserialize<'de> for QuantumProgramWrapper
impl<'de> Deserialize<'de> for QuantumProgramWrapper
sourcefn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error> where
__D: Deserializer<'de>,
Deserialize this value from the given Serde deserializer. Read more
sourceimpl IntoPy<Py<PyAny>> for QuantumProgramWrapper
impl IntoPy<Py<PyAny>> for QuantumProgramWrapper
sourceimpl PartialEq<QuantumProgramWrapper> for QuantumProgramWrapper
impl PartialEq<QuantumProgramWrapper> for QuantumProgramWrapper
sourcefn eq(&self, other: &QuantumProgramWrapper) -> bool
fn eq(&self, other: &QuantumProgramWrapper) -> bool
This method tests for self
and other
values to be equal, and is used
by ==
. Read more
sourcefn ne(&self, other: &QuantumProgramWrapper) -> bool
fn ne(&self, other: &QuantumProgramWrapper) -> bool
This method tests for !=
.
sourceimpl PyClass for QuantumProgramWrapper
impl PyClass for QuantumProgramWrapper
type Dict = PyClassDummySlot
type Dict = PyClassDummySlot
Specify this class has #[pyclass(dict)]
or not.
type WeakRef = PyClassDummySlot
type WeakRef = PyClassDummySlot
Specify this class has #[pyclass(weakref)]
or not.
type BaseNativeType = PyAny
type BaseNativeType = PyAny
The closest native ancestor. This is PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
. Read more
sourceimpl PyClassImpl for QuantumProgramWrapper
impl PyClassImpl for QuantumProgramWrapper
sourceconst DOC: &'static str = "Represents a quantum program evaluating measurements based on a one or more free float parameters.\n\nThe main use of QuantumProgram is to contain a Measurements implementing [crate::measurements::Measure]\nthat measures expectation values or output registers of [crate::Circuit] quantum circuits that contain\nsymbolic parameters. Circuit with symbolic parameters can not be simulated or executed on real hardware.\nThe symbolic parameters need to be replaced with real floating point numbers first.\nA QuantumProgram contains a list of the free parameters (`input_parameter_names`) and can automatically\nreplace the parameters with its `run` methods and return the result.\n\nThe QuantumProgram should correspond as closely as possible to a normal mulit-parameter function\nin classical computing that can be called with a set of parameters and returns a result.\nIt is the intended way to interface between normal program code and roqoqo based quantum programs.\n\u{0}"
const DOC: &'static str = "Represents a quantum program evaluating measurements based on a one or more free float parameters.\n\nThe main use of QuantumProgram is to contain a Measurements implementing [crate::measurements::Measure]\nthat measures expectation values or output registers of [crate::Circuit] quantum circuits that contain\nsymbolic parameters. Circuit with symbolic parameters can not be simulated or executed on real hardware.\nThe symbolic parameters need to be replaced with real floating point numbers first.\nA QuantumProgram contains a list of the free parameters (`input_parameter_names`) and can automatically\nreplace the parameters with its `run` methods and return the result.\n\nThe QuantumProgram should correspond as closely as possible to a normal mulit-parameter function\nin classical computing that can be called with a set of parameters and returns a result.\nIt is the intended way to interface between normal program code and roqoqo based quantum programs.\n\u{0}"
Class doc string
sourceconst IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
#[pyclass(subclass)]
sourceconst IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
#[pyclass(extends=…)]
sourceconst IS_MAPPING: bool = false
const IS_MAPPING: bool = false
#[pyclass(mapping)]
type Layout = PyCell<QuantumProgramWrapper>
type Layout = PyCell<QuantumProgramWrapper>
Layout
type ThreadChecker = ThreadCheckerStub<QuantumProgramWrapper>
type ThreadChecker = ThreadCheckerStub<QuantumProgramWrapper>
This handles following two situations: Read more
fn for_all_items(visitor: &mut dyn FnMut(&PyClassItems))
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
sourceimpl PyMethods<QuantumProgramWrapper> for PyClassImplCollector<QuantumProgramWrapper>
impl PyMethods<QuantumProgramWrapper> for PyClassImplCollector<QuantumProgramWrapper>
fn py_methods(self) -> &'static PyClassItems
sourceimpl PyTypeInfo for QuantumProgramWrapper
impl PyTypeInfo for QuantumProgramWrapper
type AsRefTarget = PyCell<QuantumProgramWrapper>
type AsRefTarget = PyCell<QuantumProgramWrapper>
Utility type to make Py::as_ref work.
sourcefn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
PyTypeObject instance for this type.
sourcefn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type or a subclass of this type.
sourcefn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
Checks if object
is an instance of this type.
sourceimpl Serialize for QuantumProgramWrapper
impl Serialize for QuantumProgramWrapper
impl StructuralPartialEq for QuantumProgramWrapper
Auto Trait Implementations
impl RefUnwindSafe for QuantumProgramWrapper
impl Send for QuantumProgramWrapper
impl Sync for QuantumProgramWrapper
impl Unpin for QuantumProgramWrapper
impl UnwindSafe for QuantumProgramWrapper
Blanket Implementations
sourceimpl<T> BorrowMut<T> for T where
T: ?Sized,
impl<T> BorrowMut<T> for T where
T: ?Sized,
const: unstable · sourcefn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more
sourceimpl<'a, T> FromPyObject<'a> for T where
T: PyClass + Clone,
impl<'a, T> FromPyObject<'a> for T where
T: PyClass + Clone,
sourceimpl<T> PyTypeObject for T where
T: PyTypeInfo,
impl<T> PyTypeObject for T where
T: PyTypeInfo,
sourcefn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
Returns the safe abstraction over the type object.
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
impl<SS, SP> SupersetOf<SS> for SP where
SS: SubsetOf<SP>,
fn to_subset(&self) -> Option<SS>
fn to_subset(&self) -> Option<SS>
The inverse inclusion map: attempts to construct self
from the equivalent element of its
superset. Read more
fn is_in_subset(&self) -> bool
fn is_in_subset(&self) -> bool
Checks if self
is actually part of its subset T
(and can be converted to it).
fn to_subset_unchecked(&self) -> SS
fn to_subset_unchecked(&self) -> SS
Use with care! Same as self.to_subset
but without any property checks. Always succeeds.
fn from_subset(element: &SS) -> SP
fn from_subset(element: &SS) -> SP
The inclusion map: converts self
to the equivalent element of its superset.
sourceimpl<T> ToOwned for T where
T: Clone,
impl<T> ToOwned for T where
T: Clone,
type Owned = T
type Owned = T
The resulting type after obtaining ownership.
sourcefn clone_into(&self, target: &mut T)
fn clone_into(&self, target: &mut T)
toowned_clone_into
)Uses borrowed data to replace owned data, usually by cloning. Read more