Module: cirq.protocols

Methods and classes that define cirq's protocols.

Modules

act_on_protocol module

apply_channel_protocol module: A protocol for implementing high performance channel evolutions.

apply_mixture_protocol module: A protocol for implementing high performance mixture evolutions.

apply_unitary_protocol module: A protocol for implementing high performance unitary left-multiplies.

approximate_equality_protocol module

circuit_diagram_info_protocol module

commutes_protocol module: Protocol for determining commutativity.

decompose_protocol module

equal_up_to_global_phase_protocol module

has_stabilizer_effect_protocol module

has_unitary_protocol module

inverse_protocol module

json_serialization module

kraus_protocol module: Protocol and methods for obtaining Kraus representation of quantum channels.

measurement_key_protocol module: Protocol for object that have measurement keys.

mixture_protocol module: Protocol for objects that are mixtures (probabilistic combinations).

mul_protocol module

pauli_expansion_protocol module: Protocol for obtaining expansion of linear operators in Pauli basis.

phase_protocol module

pow_protocol module

qid_shape_protocol module

unitary_protocol module

Classes

class ApplyChannelArgs: Arguments for efficiently performing a channel.

class ApplyMixtureArgs: Arguments for performing a mixture of unitaries.

class ApplyUnitaryArgs: Arguments for performing an efficient left-multiplication by a unitary.

class CircuitDiagramInfo: Describes how to draw an operation in a circuit diagram.

class CircuitDiagramInfoArgs: A request for information on drawing an operation in a circuit diagram.

class JsonResolver: Protocol for json resolver functions passed to read_json.

class QasmArgs

class QuilFormatter: A unique formatter to correctly output values to QUIL.

class SerializableByKey: Protocol for objects that can be serialized to a key + context.

class SupportsActOn: An object that explicitly specifies how to act on simulator states.

class SupportsActOnQubits: An object that explicitly specifies how to act on specific qubits.

class SupportsApplyChannel: An object that can efficiently implement a channel.

class SupportsApplyMixture: An object that can efficiently implement a mixture.

class SupportsApproximateEquality: Object which can be compared approximately.

class SupportsCircuitDiagramInfo: A diagrammable operation on qubits.

class SupportsCommutes: An object that can determine commutation relationships vs others.

class SupportsConsistentApplyUnitary: An object that can be efficiently left-multiplied into tensors.

class SupportsDecompose: An object that can be decomposed into simpler operations.

class SupportsDecomposeWithQubits: An object that can be decomposed into operations on given qubits.

class SupportsEqualUpToGlobalPhase: Object which can be compared for equality mod global phase.

class SupportsExplicitHasUnitary: An object that explicitly specifies whether it has a unitary effect.

class SupportsExplicitNumQubits: A unitary, channel, mixture or other object that operates on a known

class SupportsExplicitQidShape: A unitary, channel, mixture or other object that operates on a known

class SupportsJSON: An object that can be turned into JSON dictionaries.

class SupportsKraus: An object that may be describable as a quantum channel.

class SupportsMeasurementKey: An object that is a measurement and has a measurement key or keys.

class SupportsMixture: An object that decomposes into a probability distribution of unitaries.

class SupportsParameterization: An object that can be parameterized by Symbols and resolved

class SupportsPauliExpansion: An object that knows its expansion in the Pauli basis.

class SupportsPhase: An effect that can be phased around the Z axis of target qubits.

class SupportsQasm: An object that can be turned into QASM code.

class SupportsQasmWithArgs: An object that can be turned into QASM code.

class SupportsQasmWithArgsAndQubits: An object that can be turned into QASM code if it knows its qubits.

class SupportsTraceDistanceBound: An effect with known bounds on how easy it is to detect.

class SupportsUnitary: An object that may be describable by a unitary matrix.

Functions

act_on(...): Applies an action to a state argument.

apply_channel(...): High performance evolution under a channel evolution.

apply_mixture(...): High performance evolution under a mixture of unitaries evolution.

apply_unitaries(...): Apply a series of unitaries onto a state tensor.

apply_unitary(...): High performance left-multiplication of a unitary effect onto a tensor.

approx_eq(...): Approximately compares two objects.

circuit_diagram_info(...): Requests information on drawing an operation in a circuit diagram.

commutes(...): Determines whether two values commute.

dataclass_json_dict(...): Return a dictionary suitable for _jsondict from a dataclass.

decompose(...): Recursively decomposes a value into cirq.Operations meeting a criteria.

decompose_once(...): Decomposes a value into operations, if possible.

decompose_once_with_qubits(...): Decomposes a value into operations on the given qubits.

definitely_commutes(...): Determines whether two values definitely commute.

equal_up_to_global_phase(...): Determine whether two objects are equal up to global phase.

has_kraus(...): Returns whether the value has a Kraus representation.

has_mixture(...): Returns whether the value has a mixture representation.

has_stabilizer_effect(...): Returns whether the input has a stabilizer effect.

has_unitary(...): Determines whether the value has a unitary effect.

inverse(...): Returns the inverse val**-1 of the given value, if defined.

is_measurement(...): Determines whether or not the given value is a measurement (or contains one).

is_parameterized(...): Returns whether the object is parameterized with any Symbols.

json_serializable_dataclass(...): Create a dataclass that supports JSON serialization.

kraus(...): Returns a list of matrices describing the channel for the given value.

measurement_key(...): THIS FUNCTION IS DEPRECATED.

measurement_key_name(...): Get the single measurement key for the given value.

measurement_key_names(...): Gets the measurement key strings of measurements within the given value.

measurement_key_obj(...): Get the single measurement key object for the given value.

measurement_key_objs(...): Gets the measurement key objects of measurements within the given value.

measurement_keys(...): THIS FUNCTION IS DEPRECATED.

mixture(...): Return a sequence of tuples representing a probabilistic unitary.

mul(...): Returns lhs * rhs, or else a default if the operator is not implemented.

num_qubits(...): Returns the number of qubits, qudits, or qids val operates on.

obj_to_dict_helper(...): Construct a dictionary containing attributes from obj

parameter_names(...): Returns parameter names for this object.

parameter_symbols(...): Returns parameter symbols for this object.

pauli_expansion(...): Returns coefficients of the expansion of val in the Pauli basis.

phase_by(...): Returns a phased version of the effect.

pow(...): Returns val**factor of the given value, if defined.

qasm(...): Returns QASM code for the given value, if possible.

qid_shape(...): Returns a tuple describing the number of quantum levels of each

quil(...): Returns the QUIL code for the given value.

read_json(...): Read a JSON file that optionally contains cirq objects.

read_json_gzip(...)

resolve_parameters(...): Resolves symbol parameters in the effect using the param resolver.

resolve_parameters_once(...): Performs a single parameter resolution step using the param resolver.

to_json(...): Write a JSON file containing a representation of obj.

to_json_gzip(...)

trace_distance_bound(...): Returns a maximum on the trace distance between this effect's input

trace_distance_from_angle_list(...): Given a list of arguments of the eigenvalues of a unitary matrix,

unitary(...): Returns a unitary matrix describing the given value.

validate_mixture(...): Validates that the mixture's tuple are valid probabilities.

with_key_path(...): Adds the path to the target's measurement keys.

with_measurement_key_mapping(...): Remaps the target's measurement keys according to the provided key_map.

DEFAULT_RESOLVERS [<function _lazy_resolver.<locals>.json_resolver at 0x7f336f4abb90>, <function _lazy_resolver.<locals>.json_resolver at 0x7f32b1ff8320>, <function _lazy_resolver.<locals>.json_resolver at 0x7f32b2044950>, <function _lazy_resolver.<locals>.json_resolver at 0x7f32b1f49170>]