Cirq
Cirq copied to clipboard
failing comparisons for noise channels
Description of the issue
two related bugs related to equality checks for noise channels:
- approximate comparison between cirq noise channels and other gates raises an error
- exact comparison ignores
DepolarizingChannel.n_qubits
How to reproduce the issue
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_
Cirq version
1.4.0.dev20240529202703