cirq-core 1.5.0.dev20240531223815__py3-none-any.whl → 1.5.0.dev20240607171515__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Potentially problematic release.
This version of cirq-core might be problematic. Click here for more details.
- cirq/_version.py +1 -1
- cirq/_version_test.py +1 -1
- cirq/ops/pauli_string.py +21 -0
- cirq/ops/pauli_string_test.py +23 -0
- {cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/METADATA +1 -1
- {cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/RECORD +9 -9
- {cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/LICENSE +0 -0
- {cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/WHEEL +0 -0
- {cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/ops/pauli_string.py
CHANGED
|
@@ -1120,6 +1120,23 @@ def _validate_qubit_mapping(
|
|
|
1120
1120
|
)
|
|
1121
1121
|
|
|
1122
1122
|
|
|
1123
|
+
def _try_interpret_as_pauli_string(op: Any):
|
|
1124
|
+
"""Return a reprepresentation of an operation as a pauli string, if it is possible."""
|
|
1125
|
+
if isinstance(op, gate_operation.GateOperation):
|
|
1126
|
+
gates = {
|
|
1127
|
+
common_gates.XPowGate: pauli_gates.X,
|
|
1128
|
+
common_gates.YPowGate: pauli_gates.Y,
|
|
1129
|
+
common_gates.ZPowGate: pauli_gates.Z,
|
|
1130
|
+
}
|
|
1131
|
+
if (pauli := gates.get(type(op.gate), None)) is not None:
|
|
1132
|
+
exponent = op.gate.exponent # type: ignore
|
|
1133
|
+
if exponent % 2 == 0:
|
|
1134
|
+
return cirq.PauliString()
|
|
1135
|
+
if exponent % 2 == 1:
|
|
1136
|
+
return pauli.on(op.qubits[0])
|
|
1137
|
+
return None
|
|
1138
|
+
|
|
1139
|
+
|
|
1123
1140
|
# Ignoring type because mypy believes `with_qubits` methods are incompatible.
|
|
1124
1141
|
class SingleQubitPauliStringGateOperation( # type: ignore
|
|
1125
1142
|
gate_operation.GateOperation, PauliString
|
|
@@ -1159,11 +1176,15 @@ class SingleQubitPauliStringGateOperation( # type: ignore
|
|
|
1159
1176
|
return self._as_pauli_string() * other._as_pauli_string()
|
|
1160
1177
|
if isinstance(other, (PauliString, complex, float, int)):
|
|
1161
1178
|
return self._as_pauli_string() * other
|
|
1179
|
+
if (as_pauli_string := _try_interpret_as_pauli_string(other)) is not None:
|
|
1180
|
+
return self * as_pauli_string
|
|
1162
1181
|
return NotImplemented
|
|
1163
1182
|
|
|
1164
1183
|
def __rmul__(self, other):
|
|
1165
1184
|
if isinstance(other, (PauliString, complex, float, int)):
|
|
1166
1185
|
return other * self._as_pauli_string()
|
|
1186
|
+
if (as_pauli_string := _try_interpret_as_pauli_string(other)) is not None:
|
|
1187
|
+
return as_pauli_string * self
|
|
1167
1188
|
return NotImplemented
|
|
1168
1189
|
|
|
1169
1190
|
def __neg__(self):
|
cirq/ops/pauli_string_test.py
CHANGED
|
@@ -211,6 +211,29 @@ def test_list_op_constructor_matches_mapping(pauli):
|
|
|
211
211
|
assert cirq.PauliString([op]) == cirq.PauliString({q0: pauli})
|
|
212
212
|
|
|
213
213
|
|
|
214
|
+
@pytest.mark.parametrize('pauli1', (cirq.X, cirq.Y, cirq.Z))
|
|
215
|
+
@pytest.mark.parametrize('pauli2', (cirq.X, cirq.Y, cirq.Z))
|
|
216
|
+
def test_exponent_mul_consistency(pauli1, pauli2):
|
|
217
|
+
a, b = cirq.LineQubit.range(2)
|
|
218
|
+
op_a, op_b = pauli1(a), pauli2(b)
|
|
219
|
+
|
|
220
|
+
assert op_a * op_a * op_a == op_a
|
|
221
|
+
assert op_a * op_a**2 == op_a
|
|
222
|
+
assert op_a**2 * op_a == op_a
|
|
223
|
+
assert op_b * op_a * op_a == op_b
|
|
224
|
+
assert op_b * op_a**2 == op_b
|
|
225
|
+
assert op_a**2 * op_b == op_b
|
|
226
|
+
assert op_a * op_a * op_a * op_a == cirq.PauliString()
|
|
227
|
+
assert op_a * op_a**3 == cirq.PauliString()
|
|
228
|
+
assert op_b * op_a * op_a * op_a == op_b * op_a
|
|
229
|
+
assert op_b * op_a**3 == op_b * op_a
|
|
230
|
+
|
|
231
|
+
op_a, op_b = pauli1(a), pauli2(a)
|
|
232
|
+
|
|
233
|
+
assert op_a * op_b**3 == op_a * op_b * op_b * op_b
|
|
234
|
+
assert op_b**3 * op_a == op_b * op_b * op_b * op_a
|
|
235
|
+
|
|
236
|
+
|
|
214
237
|
def test_constructor_flexibility():
|
|
215
238
|
a, b = cirq.LineQubit.range(2)
|
|
216
239
|
with pytest.raises(TypeError, match='cirq.PAULI_STRING_LIKE'):
|
{cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.1
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.5.0.
|
|
3
|
+
Version: 1.5.0.dev20240607171515
|
|
4
4
|
Summary: A framework for creating, editing, and invoking Noisy Intermediate Scale Quantum (NISQ) circuits.
|
|
5
5
|
Home-page: http://github.com/quantumlib/cirq
|
|
6
6
|
Author: The Cirq Developers
|
{cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
|
|
|
4
4
|
cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
|
|
5
5
|
cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
|
|
6
6
|
cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
|
|
7
|
-
cirq/_version.py,sha256=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=N3CtNHJi_Uhc3l9epMohWPBwjLOegHqi1Zjxzcu9Jwc,1206
|
|
8
|
+
cirq/_version_test.py,sha256=OH0wy_zYf4zMe3CcEVnr0ofScvD9kV5Q3mDfoRvhZqw,147
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=ytePZtNZgKjOF2NiVpUTuotB-JKZmQNOFIFdvXqsxHw,13271
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -331,12 +331,12 @@ cirq/ops/pauli_interaction_gate.py,sha256=GQtK5lRw2Uh7hs2GsoRxe-VMlMTO8PxDeZNVT6
|
|
|
331
331
|
cirq/ops/pauli_interaction_gate_test.py,sha256=U9ORW5Ayx5PESPFiGESzWY-02qHklYcM1mYW56RWe_A,4544
|
|
332
332
|
cirq/ops/pauli_measurement_gate.py,sha256=tq_OlHlTLQa6yah--afE2UMNdF4a_vfXi8XT8ww2ELc,7215
|
|
333
333
|
cirq/ops/pauli_measurement_gate_test.py,sha256=uh3J0Ps3V3578V8qkRiEgIl6jBiv8DsXlk_vzLvOEhQ,6720
|
|
334
|
-
cirq/ops/pauli_string.py,sha256=
|
|
334
|
+
cirq/ops/pauli_string.py,sha256=WSBDv939ujl51KiE0UDsYHUk3d5B9degjNLCuFvyQ6c,67519
|
|
335
335
|
cirq/ops/pauli_string_phasor.py,sha256=F1Gftw8TDb9qdJjQti6xxbOpXbFUFCVwn3r8073wRbY,17604
|
|
336
336
|
cirq/ops/pauli_string_phasor_test.py,sha256=HGEPjPc7ySeshOnMJHNjtyckFuEXLvxgy-TtnU6fETM,27582
|
|
337
337
|
cirq/ops/pauli_string_raw_types.py,sha256=6CgdPWYmOziP4uZbrIsRW0sDSMmV1GioGdAk0owFITU,2240
|
|
338
338
|
cirq/ops/pauli_string_raw_types_test.py,sha256=SZPluslZPGffPq93F5apESBygWZ2cj7BEX6dQuawRQE,2648
|
|
339
|
-
cirq/ops/pauli_string_test.py,sha256=
|
|
339
|
+
cirq/ops/pauli_string_test.py,sha256=ekj755Fe5up8-0nXCozUlne6NCxvb8FrwZ8Qp6CAmRI,74583
|
|
340
340
|
cirq/ops/pauli_sum_exponential.py,sha256=n3fhKWJVMudzGuOcdPHskVNx3fHE2MAblVdkzbDtcz4,4909
|
|
341
341
|
cirq/ops/pauli_sum_exponential_test.py,sha256=wVnJ3FSpEimHT8ERVkmljALrgSuuDYo6GRg91uJ7ztk,5370
|
|
342
342
|
cirq/ops/permutation_gate.py,sha256=5xTXmnjFF3h8kgWV4wDnHBe4foeeqwEm-69I38WmK3k,4176
|
|
@@ -1175,8 +1175,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
|
|
|
1175
1175
|
cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
|
|
1176
1176
|
cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
|
|
1177
1177
|
cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
|
|
1178
|
-
cirq_core-1.5.0.
|
|
1179
|
-
cirq_core-1.5.0.
|
|
1180
|
-
cirq_core-1.5.0.
|
|
1181
|
-
cirq_core-1.5.0.
|
|
1182
|
-
cirq_core-1.5.0.
|
|
1178
|
+
cirq_core-1.5.0.dev20240607171515.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1179
|
+
cirq_core-1.5.0.dev20240607171515.dist-info/METADATA,sha256=4Lyw-hWTnbbrGFL7iMHxvnYGNwg3B8erDSTTPb5oqkI,1998
|
|
1180
|
+
cirq_core-1.5.0.dev20240607171515.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
|
|
1181
|
+
cirq_core-1.5.0.dev20240607171515.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1182
|
+
cirq_core-1.5.0.dev20240607171515.dist-info/RECORD,,
|
{cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/LICENSE
RENAMED
|
File without changes
|
{cirq_core-1.5.0.dev20240531223815.dist-info → cirq_core-1.5.0.dev20240607171515.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|