|  View source on GitHub | 
Mutable version of cirq.PauliString, used mainly for efficiently mutating pauli strings.
cirq.MutablePauliString(
    *contents,
    coefficient: cirq.TParamValComplex = 1,
    pauli_int_dict: (dict[TKey, int] | None) = None
)
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.
| Raises | |
|---|---|
| ValueError | If the pauli_int_dicthas integer valuesvnot satisfying1 <= v <= 3. | 
Methods
frozen
frozen() -> cirq.PauliString
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
get(
    key: TKey, default=None
) -> (cirq.Pauli | TDefault | None)
Returns the cirq.Pauli operation acting on qubit key or default if none exists.
inplace_after
inplace_after(
    ops: cirq.OP_TREE
) -> cirq.MutablePauliString
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
inplace_before(
    ops: cirq.OP_TREE
) -> cirq.MutablePauliString
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
inplace_left_multiply_by(
    other: cirq.PAULI_STRING_LIKE
) -> cirq.MutablePauliString
Left-multiplies a pauli string into this pauli string.
| Args | |
|---|---|
| other | A pauli string or cirq.PAULI_STRING_LIKEto left-multiply
intoself. | 
| Returns | |
|---|---|
| The selfmutable pauli string that was mutated. | 
| Raises | |
|---|---|
| TypeError | otherwas not acirq.PAULI_STRING_LIKE.selfwas not mutated. | 
inplace_right_multiply_by
inplace_right_multiply_by(
    other: cirq.PAULI_STRING_LIKE
) -> cirq.MutablePauliString
Right-multiplies a pauli string into this pauli string.
| Args | |
|---|---|
| other | A pauli string or cirq.PAULI_STRING_LIKEto right-multiply
intoself. | 
| Returns | |
|---|---|
| The selfmutable pauli string that was mutated. | 
| Raises | |
|---|---|
| TypeError | otherwas not acirq.PAULI_STRING_LIKE.selfwas not mutated. | 
items
items() -> Iterator[tuple[TKey, cirq.Pauli]]
Returns (cirq.Qid, cirq.Pauli) pairs representing 1-qubit operations of pauli string.
keys
keys() -> AbstractSet[TKey]
Returns the sequence of qubits on which this pauli string acts.
mutable_copy
mutable_copy() -> cirq.MutablePauliString
Returns a new cirq.MutablePauliString with the same contents.
transform_qubits
transform_qubits(
    func: Callable[[TKey], TKeyNew], *, inplace: bool = False
) -> cirq.MutablePauliString[TKeyNew]
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_qubitsin 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
values() -> Iterator[cirq.Pauli]
Ordered sequence of cirq.Pauli gates acting on self.keys().
__bool__
__bool__() -> bool
__contains__
__contains__(
    item: Any
) -> bool
__eq__
__eq__(
    other: _SupportsValueEquality
) -> bool
__getitem__
__getitem__(
    item: Any
) -> cirq.Pauli
__iter__
__iter__() -> Iterator[TKey]
__len__
__len__() -> int
__mul__
__mul__(
    other: cirq.PAULI_STRING_LIKE
) -> cirq.PauliString
Multiplies two pauli-string-likes together.
The result is not mutable.
__ne__
__ne__(
    other: _SupportsValueEquality
) -> bool
__neg__
__neg__() -> cirq.MutablePauliString
__pos__
__pos__() -> cirq.MutablePauliString
__rmul__
__rmul__(
    other: cirq.PAULI_STRING_LIKE
) -> cirq.PauliString
Multiplies two pauli-string-likes together.
The result is not mutable.