Struct qoqo::CircuitWrapper
source · pub struct CircuitWrapper {
pub internal: Circuit,
}
Expand description
Circuit of Operations.
A quantum program is represented as a linear sequence of Operations.
Fields§
§internal: Circuit
Internal storage of roqoqo::Circuit
Implementations§
source§impl CircuitWrapper
impl CircuitWrapper
sourcepub fn from_pyany(input: &Bound<'_, PyAny>) -> PyResult<Circuit>
pub fn from_pyany(input: &Bound<'_, PyAny>) -> PyResult<Circuit>
Extracts a Circuit from a CircuitWrapper python object.
When working with qoqo and other rust based python packages compiled separately a downcast will not detect that two CircuitWrapper objects are compatible. Provides a custom function to convert qoqo Circuits between different Python packages.
§Arguments:
input
- The Python object that should be casted to a roqoqo::Circuit
source§impl CircuitWrapper
impl CircuitWrapper
sourcepub fn substitute_parameters(
&self,
substitution_parameters: HashMap<String, f64>
) -> PyResult<Self>
pub fn substitute_parameters( &self, substitution_parameters: HashMap<String, f64> ) -> PyResult<Self>
Substitute the symbolic parameters in a clone of the Circuit according to the substitution_parameters input.
Args: substitution_parameters (Dict[str, float]): The dictionary containing the substitutions to use in the Circuit.
Returns: self: The Circuit with the parameters substituted.
Raises: RuntimeError: The parameter substitution failed.
sourcepub fn remap_qubits(&self, mapping: HashMap<usize, usize>) -> PyResult<Self>
pub fn remap_qubits(&self, mapping: HashMap<usize, usize>) -> PyResult<Self>
Remap qubits in operations in clone of Circuit.
Args: mapping (Dict[int, int]): The dictionary containing the {qubit: qubit} mapping to use in the Circuit.
Returns: self: The Circuit with the qubits remapped.
Raises: RuntimeError: The qubit remapping failed.
sourcepub fn overrotate(&self) -> PyResult<Self>
pub fn overrotate(&self) -> PyResult<Self>
Return clone of the circuit with all overrotation Pragmas applied.
Returns: Circuit: Circuit with the overrotation applied
Raises: RuntimeError: Error applying PragmaOverrotation in circuit. Example:
circuit = Circuit() circuit += PragmaOverrotation(“RotateY”, [1,], 20.0, 30.0) circuit += RotateX(0, 0.0) circuit += RotateY(0, 1.0) circuit += RotateY(1, 2.0) circuit += RotateY(1, 3.0) circuit_overrotated = circuit.overrotate() print(circuit) print(circuit_overrotated)
sourcepub fn count_occurences(&self, operations: Vec<String>) -> usize
pub fn count_occurences(&self, operations: Vec<String>) -> usize
Count the number of occurences of a set of operation tags in the circuit.
Args: operations (Liststr): List of operation tags that should be counted.
Returns: int: The number of occurences of these operation tags.
sourcepub fn get_operation_types(&self) -> HashSet<&str>
pub fn get_operation_types(&self) -> HashSet<&str>
Return a list of the hqslang names of all operations occuring in the circuit.
Returns: Setstr: The operation types in the Circuit.
sourcepub fn __copy__(&self) -> CircuitWrapper
pub fn __copy__(&self) -> CircuitWrapper
Return a copy of the Circuit (copy here produces a deepcopy).
Returns: Circuit: A deep copy of self.
sourcepub fn __deepcopy__(&self, _memodict: &Bound<'_, PyAny>) -> CircuitWrapper
pub fn __deepcopy__(&self, _memodict: &Bound<'_, PyAny>) -> CircuitWrapper
Return a deep copy of the Circuit.
Returns: Circuit: 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(input: &Bound<'_, PyAny>) -> PyResult<Self>
pub fn from_bincode(input: &Bound<'_, PyAny>) -> PyResult<Self>
Convert the bincode representation of the Circuit to a Circuit using the bincode crate.
Args: input (ByteArray): The serialized Circuit (in bincode form).
Returns: Circuit: The deserialized Circuit.
Raises: TypeError: Input cannot be converted to byte array. ValueError: Input cannot be deserialized to Circuit.
sourcepub fn from_json(json_string: &str) -> PyResult<Self>
pub fn from_json(json_string: &str) -> PyResult<Self>
Convert the json representation of a Circuit to a Circuit.
Args: input (str): The serialized Circuit in json form.
Returns: Circuit: The deserialized Circuit.
Raises: ValueError: Input cannot be deserialized to Circuit.
sourcepub fn get(&self, index: usize) -> PyResult<PyObject>
pub fn get(&self, index: usize) -> PyResult<PyObject>
Return a copy of the Operation at a certain index of the Circuit.
Args: index (int): The index of the Operation to get in the Circuit.
Returns: Operation: The operation at the given index (if it exists).
Raises: IndexError: Index out of range.
sourcepub fn get_slice(
&self,
start: Option<usize>,
stop: Option<usize>
) -> PyResult<CircuitWrapper>
pub fn get_slice( &self, start: Option<usize>, stop: Option<usize> ) -> PyResult<CircuitWrapper>
Return the copy of a slice of the Circuit.
Args: start (Optional[int]): The starting index of the slice (inclusive). stop (Optional[int]): The stopping index of the slice (exclusive).
Returns: Circuit: The slice of the operations in the Circuit with the specified indices.
Raises: IndexError: Stop index smaller than start index. IndexError: Stop index out of range. IndexError: Start index out of range.
sourcepub fn definitions(&self) -> PyResult<Vec<PyObject>>
pub fn definitions(&self) -> PyResult<Vec<PyObject>>
Return a list of definitions in the Circuit.
Definitions need to be unique.
Returns: List[Operation]: A vector of the definitions in the Circuit.
sourcepub fn operations(&self) -> PyResult<Vec<PyObject>>
pub fn operations(&self) -> PyResult<Vec<PyObject>>
Return a list of all operations in the Circuit.
Returns: List[Operation]: A vector of the operations in the Circuit.
Trait Implementations§
source§impl Clone for CircuitWrapper
impl Clone for CircuitWrapper
source§fn clone(&self) -> CircuitWrapper
fn clone(&self) -> CircuitWrapper
1.0.0 · source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source
. Read moresource§impl Debug for CircuitWrapper
impl Debug for CircuitWrapper
source§impl Default for CircuitWrapper
impl Default for CircuitWrapper
source§impl HasPyGilRef for CircuitWrapper
impl HasPyGilRef for CircuitWrapper
§type AsRefTarget = PyCell<CircuitWrapper>
type AsRefTarget = PyCell<CircuitWrapper>
source§impl PartialEq for CircuitWrapper
impl PartialEq for CircuitWrapper
source§fn eq(&self, other: &CircuitWrapper) -> bool
fn eq(&self, other: &CircuitWrapper) -> bool
self
and other
values to be equal, and is used
by ==
.source§impl PyClassImpl for CircuitWrapper
impl PyClassImpl for CircuitWrapper
source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
§type ThreadChecker = SendablePyClass<CircuitWrapper>
type ThreadChecker = SendablePyClass<CircuitWrapper>
type Inventory = Pyo3MethodsInventoryForCircuitWrapper
§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny
by default, and when you declare
#[pyclass(extends=PyDict)]
, it’s PyDict
.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
source§impl PyClassNewTextSignature<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
impl PyClassNewTextSignature<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
fn new_text_signature(self) -> Option<&'static str>
source§impl PyClass__add__SlotFragment<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
impl PyClass__add__SlotFragment<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
source§impl PyClass__setitem__SlotFragment<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
impl PyClass__setitem__SlotFragment<CircuitWrapper> for PyClassImplCollector<CircuitWrapper>
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a CircuitWrapper
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a CircuitWrapper
source§impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut CircuitWrapper
impl<'a, 'py> PyFunctionArgument<'a, 'py> for &'a mut CircuitWrapper
source§impl PyTypeInfo for CircuitWrapper
impl PyTypeInfo for CircuitWrapper
source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
source§fn type_object(py: Python<'_>) -> &PyType
fn type_object(py: Python<'_>) -> &PyType
PyTypeInfo::type_object
will be replaced by PyTypeInfo::type_object_bound
in a future PyO3 versionsource§fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
fn type_object_bound(py: Python<'_>) -> Bound<'_, PyType>
source§fn is_type_of(object: &PyAny) -> bool
fn is_type_of(object: &PyAny) -> bool
PyTypeInfo::is_type_of
will be replaced by PyTypeInfo::is_type_of_bound
in a future PyO3 versionobject
is an instance of this type or a subclass of this type.source§fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
fn is_type_of_bound(object: &Bound<'_, PyAny>) -> bool
object
is an instance of this type or a subclass of this type.source§fn is_exact_type_of(object: &PyAny) -> bool
fn is_exact_type_of(object: &PyAny) -> bool
PyTypeInfo::is_exact_type_of
will be replaced by PyTypeInfo::is_exact_type_of_bound
in a future PyO3 versionobject
is an instance of this type.impl DerefToPyAny for CircuitWrapper
impl StructuralPartialEq for CircuitWrapper
Auto Trait Implementations§
impl Freeze for CircuitWrapper
impl RefUnwindSafe for CircuitWrapper
impl Send for CircuitWrapper
impl Sync for CircuitWrapper
impl Unpin for CircuitWrapper
impl UnwindSafe for CircuitWrapper
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> FromPyObject<'_> for T
impl<T> FromPyObject<'_> for T
source§impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
impl<'py, T> FromPyObjectBound<'_, 'py> for Twhere
T: FromPyObject<'py>,
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<T> PyErrArguments for T
impl<T> PyErrArguments for T
source§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
source§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.