Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

failing comparisons for noise channels #6631

Open
richrines1 opened this issue Jun 3, 2024 · 0 comments · May be fixed by #6632
Open

failing comparisons for noise channels #6631

richrines1 opened this issue Jun 3, 2024 · 0 comments · May be fixed by #6632
Labels
kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add

Comments

@richrines1
Copy link
Contributor

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
@richrines1 richrines1 added the kind/bug-report Something doesn't seem to work. label Jun 3, 2024
@NoureldinYosri NoureldinYosri added the triage/discuss Needs decision / discussion, bring these up during Cirq Cynque label Jun 3, 2024
@richrines1 richrines1 linked a pull request Jun 3, 2024 that will close this issue
@NoureldinYosri NoureldinYosri added triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add and removed triage/discuss Needs decision / discussion, bring these up during Cirq Cynque labels Jun 12, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
kind/bug-report Something doesn't seem to work. triage/accepted there is consensus amongst maintainers that this is a real bug or a reasonable feature to add
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants