cirq.approx_eq(cirq.depolarize(0.1), cirq.X) # AttributeError: '_PauliX' object has no attribute 'p'
cirq.approx_eq(cirq.phase_damp(0.1), cirq.X) # AttributeError: '_PauliX' object has no attribute '_gamma'
cirq.approx_eq(cirq.phase_flip(0.1), cirq.X) # AttributeError: '_PauliX' object has no attribute '_p'
cirq.approx_eq(cirq.bit_flip(0.1), cirq.X) # AttributeError: '_PauliX' object has no attribute '_p'
cirq.approx_eq(cirq.asymmetric_depolarize(0.1), cirq.X) # AttributeError: '_PauliX' object has no attribute 'error_probabilities'
assert cirq.depolarize(0.1, 1) == cirq.depolarize(0.1, 2) # passes, but shouldn't
i believe the first issue would be fixed by just adding approximate=True to the @value_equality decorator for each class and removing their explicit implementations of _approx_eq_. The second issue just requires the inclusion of n_qubits in DepolarizingChannel._value_equality_values_
Description of the issue
two related bugs related to equality checks for noise channels:
DepolarizingChannel.n_qubits
How to reproduce the issue
i believe the first issue would be fixed by just adding
approximate=True
to the@value_equality
decorator for each class and removing their explicit implementations of_approx_eq_
. The second issue just requires the inclusion ofn_qubits
inDepolarizingChannel._value_equality_values_
Cirq version