Skip to content

cirq.MutablePauliString supports identity gates but cirq.PauliString doesn't, which leads to inconsistencies #5572

@tanujkhattar

Description

@tanujkhattar

Description of the issue
cirq.MutablePauliString seems to support identity gates (for example: when passed in pauli_int_dict parameter). The type annotations on on methods like .values() and .items() also have a Union[Pauli, IdentityGate].

This is bad because cirq.PauliString does not support identity gates and hence this leads to inconsistencies between the mutable vs the non-mutable version.

How to reproduce the issue

>>> q = cirq.LineQubit.range(3)
>>> mps = cirq.MutablePauliString(pauli_int_dict={q[0] : 0, q[1] : 1, q[2] : 2})
>>> [*mps.values()]
[cirq.I, cirq.X, cirq.Y]
>>> [*eval(repr(mps)).values()]
[cirq.X, cirq.Y]

Cirq version
0.15dev

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions