cirq.MutablePauliString

Mutable version of cirq.PauliString, used mainly for efficiently mutating pauli strings.

cirq.MutablePauliString is a mutable version of cirq.PauliString, which is often useful for mutating pauli strings efficiently instead of always creating a copy. Note that, unlike cirq.PauliString, MutablePauliString is not a cirq.Operation.

It exists mainly to help mutate pauli strings efficiently and then convert back to a frozen cirq.PauliString representation, which can then be used as operators or observables.

*contents A value or values to convert into a pauli string. This can be a number, a pauli operation, a dictionary from qubit to pauli/identity gates, or collections thereof. If a list of values is given, they are each individually converted and then multiplied from left to right in order.
coefficient Initial scalar coefficient or symbol. Defaults to 1.
pauli_int_dict Initial dictionary mapping qubits to integers corresponding to pauli operations. Defaults to the empty dictionary. Note that, unlike dictionaries passed to contents, this dictionary must not contain values corresponding to identity gates; i.e. all integer values must be between [1, 3]. Further note that this argument specifies values that are logically before factors specified in contents; contents are right multiplied onto the values in this dictionary.

ValueError If the pauli_int_dict has integer values v not satisfying 1 <= v <= 3.

Methods

frozen

View source

Returns a cirq.PauliString with the same contents.

For example, this is useful because cirq.PauliString is an operation whereas cirq.MutablePauliString is not.

get

View source

Returns the cirq.Pauli operation acting on qubit key or default if none exists.

inplace_after

View source

Propagates the pauli string from before to after a Clifford effect.

If the old value of the MutablePauliString is \(P\) and the Clifford operation is \(C\), then the new value of the MutablePauliString is \(C P C^\dagger\).

Args
ops A stabilizer operation or nested collection of stabilizer operations.

Returns
The mutable pauli string that was mutated.

Raises
NotImplementedError If any ops decompose into an unsupported Clifford gate.

inplace_before

View source

Propagates the pauli string from after to before a Clifford effect.

If the old value of the MutablePauliString is \(P\) and the Clifford operation is \(C\), then the new value of the MutablePauliString is \(C^\dagger P C\).

Args
ops A stabilizer operation or nested collection of stabilizer operations.

Returns
The mutable pauli string that was mutated.

inplace_left_multiply_by

View source

Left-multiplies a pauli string into this pauli string.

Args
other A pauli string or cirq.PAULI_STRING_LIKE to left-multiply into self.

Returns
The self mutable pauli string that was mutated.

Raises
TypeError other was not a cirq.PAULI_STRING_LIKE. self was not mutated.

inplace_right_multiply_by

View source

Right-multiplies a pauli string into this pauli string.

Args
other A pauli string or cirq.PAULI_STRING_LIKE to right-multiply into self.

Returns
The self mutable pauli string that was mutated.

Raises
TypeError other was not a cirq.PAULI_STRING_LIKE. self was not mutated.

items

View source

Returns (cirq.Qid, cirq.Pauli) pairs representing 1-qubit operations of pauli string.

keys

View source

Returns the sequence of qubits on which this pauli string acts.

mutable_copy

View source

Returns a new cirq.MutablePauliString with the same contents.

transform_qubits

View source

Returns a MutablePauliString with transformed qubits.

Args
func The qubit transformation to apply.
inplace If false (the default), creates a new mutable pauli string to store the result. If true, overwrites this mutable pauli string's contents. Defaults to false for consistency with cirq.PauliString.transform_qubits in situations where the pauli string being used may or may not be mutable.

Returns
A transformed MutablePauliString. If inplace=True, returns self. If inplace=False, returns a new instance.

values

View source

Ordered sequence of cirq.Pauli gates acting on self.keys().

__bool__

View source

__contains__

View source

__eq__

View source

__getitem__

View source

__iter__

View source

__len__

View source

__mul__

View source

Multiplies two pauli-string-likes together.

The result is not mutable.

__ne__

View source

__neg__

View source

__pos__

View source

__rmul__

View source

Multiplies two pauli-string-likes together.

The result is not mutable.