forked from quantumlib/Cirq
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Make
PauliMeasurementGate
respect sign of the pauli observable. (qu…
…antumlib#4836) Fixes quantumlib#4814 Note that this is a breaking change because: - Serialization of the `PauliMeasurementGate` is now different -- the serialized observable is `DensePauliString` instead of a tuple of Pauli's. - A DensePauliString with coefficient != +1/-1 will now raise a `ValueError` whereas earlier the coefficient was simply ignored.
- Loading branch information
1 parent
8806516
commit 21978e5
Showing
6 changed files
with
158 additions
and
56 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,42 +1,53 @@ | ||
[{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": [ | ||
{ | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
[ | ||
{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": { | ||
"cirq_type": "DensePauliString", | ||
"pauli_mask": [ | ||
1, | ||
2, | ||
3 | ||
], | ||
"coefficient": { | ||
"cirq_type": "complex", | ||
"real": 1.0, | ||
"imag": 0.0 | ||
} | ||
}, | ||
{ | ||
"cirq_type": "_PauliY", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
"key": "key" | ||
}, | ||
{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": { | ||
"cirq_type": "DensePauliString", | ||
"pauli_mask": [ | ||
1, | ||
2, | ||
3 | ||
], | ||
"coefficient": { | ||
"cirq_type": "complex", | ||
"real": 1.0, | ||
"imag": 0.0 | ||
} | ||
}, | ||
{ | ||
"cirq_type": "_PauliZ", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
} | ||
], | ||
"key": "key" | ||
}, | ||
{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": [ | ||
{ | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
"key": "p:q:key" | ||
}, | ||
{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": { | ||
"cirq_type": "DensePauliString", | ||
"pauli_mask": [ | ||
1, | ||
2, | ||
3 | ||
], | ||
"coefficient": { | ||
"cirq_type": "complex", | ||
"real": -1.0, | ||
"imag": 0.0 | ||
} | ||
}, | ||
{ | ||
"cirq_type": "_PauliY", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
{ | ||
"cirq_type": "_PauliZ", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
} | ||
], | ||
"key": "p:q:key" | ||
}] | ||
"key": "key" | ||
} | ||
] |
42 changes: 42 additions & 0 deletions
42
cirq/protocols/json_test_data/PauliMeasurementGate.json_inward
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,42 @@ | ||
[{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": [ | ||
{ | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
{ | ||
"cirq_type": "_PauliY", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
{ | ||
"cirq_type": "_PauliZ", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
} | ||
], | ||
"key": "key" | ||
}, | ||
{ | ||
"cirq_type": "PauliMeasurementGate", | ||
"observable": [ | ||
{ | ||
"cirq_type": "_PauliX", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
{ | ||
"cirq_type": "_PauliY", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
}, | ||
{ | ||
"cirq_type": "_PauliZ", | ||
"exponent": 1.0, | ||
"global_shift": 0.0 | ||
} | ||
], | ||
"key": "p:q:key" | ||
}] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,6 @@ | ||
[ | ||
cirq.PauliMeasurementGate((cirq.X, cirq.Y, cirq.Z), cirq.MeasurementKey(name='key')), | ||
cirq.PauliMeasurementGate((cirq.X, cirq.Y, cirq.Z), cirq.MeasurementKey(path=('p', 'q'), name='key')), | ||
cirq.PauliMeasurementGate(cirq.DensePauliString("XYZ"), cirq.MeasurementKey(path=('p', 'q'), name='key')), | ||
cirq.PauliMeasurementGate(cirq.DensePauliString("XYZ", coefficient=-1), cirq.MeasurementKey(name='key')), | ||
] | ||
|
5 changes: 5 additions & 0 deletions
5
cirq/protocols/json_test_data/PauliMeasurementGate.repr_inward
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
[ | ||
cirq.PauliMeasurementGate((cirq.X, cirq.Y, cirq.Z), cirq.MeasurementKey(name='key')), | ||
cirq.PauliMeasurementGate((cirq.X, cirq.Y, cirq.Z), cirq.MeasurementKey(path=('p', 'q'), name='key')), | ||
] | ||
|