-
Notifications
You must be signed in to change notification settings - Fork 651
Reject multi-qubit noise channels with clear error message #1020
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
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -720,6 +720,16 @@ def test_serialize_noise_channel_unsupported_value(self): | |||||||||||||||||||||||||||||||||||||||||||||
| with self.assertRaises(ValueError): | ||||||||||||||||||||||||||||||||||||||||||||||
| serializer.serialize_circuit(simple_circuit) | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| def test_serialize_multi_qubit_noise_channel(self): | ||||||||||||||||||||||||||||||||||||||||||||||
| """Ensure multi-qubit noise channels are rejected with clear error.""" | ||||||||||||||||||||||||||||||||||||||||||||||
| q0 = cirq.GridQubit(0, 0) | ||||||||||||||||||||||||||||||||||||||||||||||
| q1 = cirq.GridQubit(0, 1) | ||||||||||||||||||||||||||||||||||||||||||||||
| multi_qubit_circuit = cirq.Circuit( | ||||||||||||||||||||||||||||||||||||||||||||||
| cirq.DepolarizingChannel(p=0.1, n_qubits=2)(q0, q1)) | ||||||||||||||||||||||||||||||||||||||||||||||
| with self.assertRaisesRegex(ValueError, | ||||||||||||||||||||||||||||||||||||||||||||||
| "Multi-qubit noise channels"): | ||||||||||||||||||||||||||||||||||||||||||||||
| serializer.serialize_circuit(multi_qubit_circuit) | ||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+723
to
+731
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Great job on adding a test for this new validation! To make it more robust, I suggest expanding it to also test Additionally, the
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
| @parameterized.parameters([{'inp': v} for v in ['wrong', 1.0, None, []]]) | ||||||||||||||||||||||||||||||||||||||||||||||
| def test_serialize_circuit_wrong_type(self, inp): | ||||||||||||||||||||||||||||||||||||||||||||||
| """Attempt to serialize invalid objects types.""" | ||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.