cirq-core 1.6.0.dev20250522221502__py3-none-any.whl → 1.6.0.dev20250523155818__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/common_gates.py +24 -64
- cirq/ops/common_gates_test.py +19 -15
- cirq/ops/controlled_gate.py +1 -6
- {cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/METADATA +1 -1
- {cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/RECORD +10 -10
- {cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/WHEEL +0 -0
- {cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/licenses/LICENSE +0 -0
- {cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/top_level.txt +0 -0
cirq/_version.py
CHANGED
cirq/_version_test.py
CHANGED
cirq/ops/common_gates.py
CHANGED
|
@@ -222,25 +222,17 @@ class XPowGate(eigen_gate.EigenGate):
|
|
|
222
222
|
A `cirq.ControlledGate` (or `cirq.CXPowGate` if possible) representing
|
|
223
223
|
`self` controlled by the given control values and qubits.
|
|
224
224
|
"""
|
|
225
|
-
if control_values and not isinstance(control_values, cv.AbstractControlValues):
|
|
226
|
-
control_values = cv.ProductOfSums(
|
|
227
|
-
tuple(
|
|
228
|
-
(val,) if isinstance(val, int) else tuple(sorted(val)) for val in control_values
|
|
229
|
-
)
|
|
230
|
-
)
|
|
231
225
|
result = super().controlled(num_controls, control_values, control_qid_shape)
|
|
232
226
|
if (
|
|
233
227
|
self._global_shift == 0
|
|
234
228
|
and isinstance(result, controlled_gate.ControlledGate)
|
|
235
229
|
and isinstance(result.control_values, cv.ProductOfSums)
|
|
236
|
-
and result.control_values
|
|
237
|
-
and result.control_qid_shape[-1] == 2
|
|
230
|
+
and result.control_values.is_trivial
|
|
238
231
|
):
|
|
239
|
-
|
|
240
|
-
exponent=self._exponent
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
)
|
|
232
|
+
if result.control_qid_shape == (2,):
|
|
233
|
+
return cirq.CXPowGate(exponent=self._exponent)
|
|
234
|
+
if result.control_qid_shape == (2, 2):
|
|
235
|
+
return cirq.CCXPowGate(exponent=self._exponent)
|
|
244
236
|
return result
|
|
245
237
|
|
|
246
238
|
def _pauli_expansion_(self) -> value.LinearDict[str]:
|
|
@@ -694,25 +686,17 @@ class ZPowGate(eigen_gate.EigenGate):
|
|
|
694
686
|
A `cirq.ControlledGate` (or `cirq.CZPowGate` if possible) representing
|
|
695
687
|
`self` controlled by the given control values and qubits.
|
|
696
688
|
"""
|
|
697
|
-
if control_values and not isinstance(control_values, cv.AbstractControlValues):
|
|
698
|
-
control_values = cv.ProductOfSums(
|
|
699
|
-
tuple(
|
|
700
|
-
(val,) if isinstance(val, int) else tuple(sorted(val)) for val in control_values
|
|
701
|
-
)
|
|
702
|
-
)
|
|
703
689
|
result = super().controlled(num_controls, control_values, control_qid_shape)
|
|
704
690
|
if (
|
|
705
691
|
self._global_shift == 0
|
|
706
692
|
and isinstance(result, controlled_gate.ControlledGate)
|
|
707
693
|
and isinstance(result.control_values, cv.ProductOfSums)
|
|
708
|
-
and result.control_values
|
|
709
|
-
and result.control_qid_shape[-1] == 2
|
|
694
|
+
and result.control_values.is_trivial
|
|
710
695
|
):
|
|
711
|
-
|
|
712
|
-
exponent=self._exponent
|
|
713
|
-
|
|
714
|
-
|
|
715
|
-
)
|
|
696
|
+
if result.control_qid_shape == (2,):
|
|
697
|
+
return cirq.CZPowGate(exponent=self._exponent)
|
|
698
|
+
if result.control_qid_shape == (2, 2):
|
|
699
|
+
return cirq.CCZPowGate(exponent=self._exponent)
|
|
716
700
|
return result
|
|
717
701
|
|
|
718
702
|
def _qid_shape_(self) -> tuple[int, ...]:
|
|
@@ -1138,26 +1122,14 @@ class CZPowGate(gate_features.InterchangeableQubitsGate, eigen_gate.EigenGate):
|
|
|
1138
1122
|
A `cirq.ControlledGate` (or `cirq.CCZPowGate` if possible) representing
|
|
1139
1123
|
`self` controlled by the given control values and qubits.
|
|
1140
1124
|
"""
|
|
1141
|
-
if control_values and not isinstance(control_values, cv.AbstractControlValues):
|
|
1142
|
-
control_values = cv.ProductOfSums(
|
|
1143
|
-
tuple(
|
|
1144
|
-
(val,) if isinstance(val, int) else tuple(sorted(val)) for val in control_values
|
|
1145
|
-
)
|
|
1146
|
-
)
|
|
1147
1125
|
result = super().controlled(num_controls, control_values, control_qid_shape)
|
|
1148
|
-
if (
|
|
1149
|
-
|
|
1150
|
-
|
|
1151
|
-
|
|
1152
|
-
|
|
1153
|
-
|
|
1154
|
-
)
|
|
1155
|
-
return cirq.CCZPowGate(
|
|
1156
|
-
exponent=self._exponent, global_shift=self._global_shift
|
|
1157
|
-
).controlled(
|
|
1158
|
-
result.num_controls() - 1, result.control_values[:-1], result.control_qid_shape[:-1]
|
|
1159
|
-
)
|
|
1160
|
-
return result
|
|
1126
|
+
if self._global_shift != 0 or not isinstance(result, controlled_gate.ControlledGate):
|
|
1127
|
+
return result
|
|
1128
|
+
return ZPowGate(exponent=self.exponent).controlled(
|
|
1129
|
+
num_controls=result.num_controls() + 1,
|
|
1130
|
+
control_values=result.control_values & cv.ProductOfSums([1]),
|
|
1131
|
+
control_qid_shape=result.control_qid_shape + (2,),
|
|
1132
|
+
)
|
|
1161
1133
|
|
|
1162
1134
|
def _circuit_diagram_info_(self, args: cirq.CircuitDiagramInfoArgs) -> cirq.CircuitDiagramInfo:
|
|
1163
1135
|
return protocols.CircuitDiagramInfo(
|
|
@@ -1340,26 +1312,14 @@ class CXPowGate(eigen_gate.EigenGate):
|
|
|
1340
1312
|
A `cirq.ControlledGate` (or `cirq.CCXPowGate` if possible) representing
|
|
1341
1313
|
`self` controlled by the given control values and qubits.
|
|
1342
1314
|
"""
|
|
1343
|
-
if control_values and not isinstance(control_values, cv.AbstractControlValues):
|
|
1344
|
-
control_values = cv.ProductOfSums(
|
|
1345
|
-
tuple(
|
|
1346
|
-
(val,) if isinstance(val, int) else tuple(sorted(val)) for val in control_values
|
|
1347
|
-
)
|
|
1348
|
-
)
|
|
1349
1315
|
result = super().controlled(num_controls, control_values, control_qid_shape)
|
|
1350
|
-
if (
|
|
1351
|
-
|
|
1352
|
-
|
|
1353
|
-
|
|
1354
|
-
|
|
1355
|
-
|
|
1356
|
-
)
|
|
1357
|
-
return cirq.CCXPowGate(
|
|
1358
|
-
exponent=self._exponent, global_shift=self._global_shift
|
|
1359
|
-
).controlled(
|
|
1360
|
-
result.num_controls() - 1, result.control_values[:-1], result.control_qid_shape[:-1]
|
|
1361
|
-
)
|
|
1362
|
-
return result
|
|
1316
|
+
if self._global_shift != 0 or not isinstance(result, controlled_gate.ControlledGate):
|
|
1317
|
+
return result
|
|
1318
|
+
return XPowGate(exponent=self.exponent).controlled(
|
|
1319
|
+
num_controls=result.num_controls() + 1,
|
|
1320
|
+
control_values=result.control_values & cv.ProductOfSums([1]),
|
|
1321
|
+
control_qid_shape=result.control_qid_shape + (2,),
|
|
1322
|
+
)
|
|
1363
1323
|
|
|
1364
1324
|
def _qasm_(self, args: cirq.QasmArgs, qubits: tuple[cirq.Qid, ...]) -> str | None:
|
|
1365
1325
|
if self._exponent != 1:
|
cirq/ops/common_gates_test.py
CHANGED
|
@@ -109,19 +109,19 @@ def test_z_init():
|
|
|
109
109
|
|
|
110
110
|
|
|
111
111
|
@pytest.mark.parametrize(
|
|
112
|
-
'input_gate, specialized_output',
|
|
112
|
+
'input_gate, specialized_output, base_gate',
|
|
113
113
|
[
|
|
114
|
-
(cirq.Z, cirq.CZ),
|
|
115
|
-
(cirq.CZ, cirq.CCZ),
|
|
116
|
-
(cirq.X, cirq.CX),
|
|
117
|
-
(cirq.CX, cirq.CCX),
|
|
118
|
-
(cirq.ZPowGate(exponent=0.5), cirq.CZPowGate(exponent=0.5)),
|
|
119
|
-
(cirq.CZPowGate(exponent=0.5), cirq.CCZPowGate(exponent=0.5)),
|
|
120
|
-
(cirq.XPowGate(exponent=0.5), cirq.CXPowGate(exponent=0.5)),
|
|
121
|
-
(cirq.CXPowGate(exponent=0.5), cirq.CCXPowGate(exponent=0.5)),
|
|
114
|
+
(cirq.Z, cirq.CZ, cirq.Z),
|
|
115
|
+
(cirq.CZ, cirq.CCZ, cirq.Z),
|
|
116
|
+
(cirq.X, cirq.CX, cirq.X),
|
|
117
|
+
(cirq.CX, cirq.CCX, cirq.X),
|
|
118
|
+
(cirq.ZPowGate(exponent=0.5), cirq.CZPowGate(exponent=0.5), cirq.S),
|
|
119
|
+
(cirq.CZPowGate(exponent=0.5), cirq.CCZPowGate(exponent=0.5), cirq.S),
|
|
120
|
+
(cirq.XPowGate(exponent=0.5), cirq.CXPowGate(exponent=0.5), cirq.XPowGate(exponent=0.5)),
|
|
121
|
+
(cirq.CXPowGate(exponent=0.5), cirq.CCXPowGate(exponent=0.5), cirq.XPowGate(exponent=0.5)),
|
|
122
122
|
],
|
|
123
123
|
)
|
|
124
|
-
def test_specialized_control(input_gate, specialized_output):
|
|
124
|
+
def test_specialized_control(input_gate, specialized_output, base_gate):
|
|
125
125
|
# Single qubit control on the input gate gives the specialized output
|
|
126
126
|
assert input_gate.controlled() == specialized_output
|
|
127
127
|
assert input_gate.controlled(num_controls=1) == specialized_output
|
|
@@ -151,20 +151,24 @@ def test_specialized_control(input_gate, specialized_output):
|
|
|
151
151
|
)
|
|
152
152
|
|
|
153
153
|
# When a control_value 1 qubit is not acting first, results in a regular
|
|
154
|
-
# ControlledGate on the
|
|
154
|
+
# ControlledGate on the base gate instance, with any extra control layer
|
|
155
|
+
# of the input gate being absorbed into the ControlledGate.
|
|
156
|
+
absorbed = 0 if base_gate == input_gate else 1
|
|
157
|
+
absorbed_values = ((1,),) * absorbed
|
|
158
|
+
absorbed_shape = (2,) * absorbed
|
|
155
159
|
assert input_gate.controlled(num_controls=1, control_qid_shape=(3,)) == cirq.ControlledGate(
|
|
156
|
-
|
|
160
|
+
base_gate, num_controls=1 + absorbed, control_qid_shape=(3,) + absorbed_shape
|
|
157
161
|
)
|
|
158
162
|
assert input_gate.controlled(control_values=((0,), (1,), (0,))) == cirq.ControlledGate(
|
|
159
|
-
|
|
163
|
+
base_gate, num_controls=3 + absorbed, control_values=((0,), (1,), (0,)) + absorbed_values
|
|
160
164
|
)
|
|
161
165
|
assert input_gate.controlled(control_qid_shape=(3, 2, 3)) == cirq.ControlledGate(
|
|
162
|
-
|
|
166
|
+
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 3) + absorbed_shape
|
|
163
167
|
)
|
|
164
168
|
assert input_gate.controlled(control_qid_shape=(3,)).controlled(
|
|
165
169
|
control_qid_shape=(2,)
|
|
166
170
|
).controlled(control_qid_shape=(4,)) != cirq.ControlledGate(
|
|
167
|
-
|
|
171
|
+
base_gate, num_controls=3 + absorbed, control_qid_shape=(3, 2, 4) + absorbed_shape
|
|
168
172
|
)
|
|
169
173
|
|
|
170
174
|
|
cirq/ops/controlled_gate.py
CHANGED
|
@@ -151,12 +151,7 @@ class ControlledGate(raw_types.Gate):
|
|
|
151
151
|
)
|
|
152
152
|
# Prefer the subgate controlled version if available
|
|
153
153
|
if self != controlled_sub_gate:
|
|
154
|
-
|
|
155
|
-
# TODO: Remove after #7241 is resolved
|
|
156
|
-
if not isinstance(controlled_sub_gate, ControlledGate) or not isinstance(
|
|
157
|
-
controlled_sub_gate.sub_gate, common_gates.CZPowGate
|
|
158
|
-
):
|
|
159
|
-
return controlled_sub_gate.on(*qubits)
|
|
154
|
+
return controlled_sub_gate.on(*qubits)
|
|
160
155
|
if (
|
|
161
156
|
protocols.has_unitary(self.sub_gate)
|
|
162
157
|
and protocols.num_qubits(self.sub_gate) == 1
|
{cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: cirq-core
|
|
3
|
-
Version: 1.6.0.
|
|
3
|
+
Version: 1.6.0.dev20250523155818
|
|
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.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/RECORD
RENAMED
|
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=ZSmenkbqEfRJpGsvutmV8vgIlfZCWj8GAVgi3t5YRso,34635
|
|
|
4
4
|
cirq/_doc.py,sha256=BrnoABo1hk5RgB3Cgww4zLHUfiyFny0F1V-tOMCbdaU,2909
|
|
5
5
|
cirq/_import.py,sha256=ixBu4EyGl46Ram2cP3p5eZVEFDW5L2DS-VyTjz4N9iw,8429
|
|
6
6
|
cirq/_import_test.py,sha256=oF4izzOVZLc7NZ0aZHFcGv-r01eiFFt_JORx_x7_D4s,1089
|
|
7
|
-
cirq/_version.py,sha256=
|
|
8
|
-
cirq/_version_test.py,sha256=
|
|
7
|
+
cirq/_version.py,sha256=LLxwzI15uCCvDa3SM2lM_PHPTGZ3HWJS66wMi96J36U,1206
|
|
8
|
+
cirq/_version_test.py,sha256=oSKD2eT8ftngXLKW-pqKeA7vt83MJrXqgjbuS7WN0Tc,155
|
|
9
9
|
cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
|
|
10
10
|
cirq/json_resolver_cache.py,sha256=S-zUVI4D_XnAxyR6z7WHDImCVmB_awJp6EStD1-CNPU,13621
|
|
11
11
|
cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
|
|
@@ -283,11 +283,11 @@ cirq/ops/common_channels.py,sha256=BD8-qJDGITOSP0bJVcWGgjbI5dj2dwFkSzzWb-qgfcc,3
|
|
|
283
283
|
cirq/ops/common_channels_test.py,sha256=Qzw7nDrWgO1GDB7qkN2YUZi3NDswvvBJ9TEnSNakJX4,30755
|
|
284
284
|
cirq/ops/common_gate_families.py,sha256=trK4ZXCKqYahZkyuwaAn-TcjUu7gmI9n9geO8PYiRGE,8606
|
|
285
285
|
cirq/ops/common_gate_families_test.py,sha256=uePsNHQJG7zr28P5KYBBiRQHtl5nYl3tYPVjl5jH4mM,5312
|
|
286
|
-
cirq/ops/common_gates.py,sha256=
|
|
287
|
-
cirq/ops/common_gates_test.py,sha256=
|
|
286
|
+
cirq/ops/common_gates.py,sha256=uNDMUj3mru-WsfLPJrxtiXfKfsZ5y8y3Ngha0AsZaXs,56206
|
|
287
|
+
cirq/ops/common_gates_test.py,sha256=Yan_k_H8xBmBWAWpKdB-gZIbhlA6vo0EpTjCKMJgt1Q,47367
|
|
288
288
|
cirq/ops/control_values.py,sha256=GrNi8YJZSZDCl8Su6Ocimvd1R1SejFJjVu2thcJ8VLI,13346
|
|
289
289
|
cirq/ops/control_values_test.py,sha256=JYaFLJSIqZSaQ94y0kyWRRVzcQ9mgc6-s1ws2q4EiAg,12943
|
|
290
|
-
cirq/ops/controlled_gate.py,sha256=
|
|
290
|
+
cirq/ops/controlled_gate.py,sha256=8VRUW95foVgPTFwDvuBnT84M8LiGH4pzpRZVaDOAtHk,15331
|
|
291
291
|
cirq/ops/controlled_gate_test.py,sha256=VcBb572S17Boe70TJddU-sqhaJqZSUKiqGstJzSspsE,26765
|
|
292
292
|
cirq/ops/controlled_operation.py,sha256=l0pjUfru39HBuAbBkRCqJmrJDxah0JOFxXXILcUt0v8,13978
|
|
293
293
|
cirq/ops/controlled_operation_test.py,sha256=qXpnUoeWmOQaTMZPAuuICtX9Idf-JWtdARTsTENv54g,16546
|
|
@@ -1220,8 +1220,8 @@ cirq/work/sampler.py,sha256=rxbMWvrhu3gfNSBjZKozw28lLKVvBAS_1EGyPdYe8Xg,19041
|
|
|
1220
1220
|
cirq/work/sampler_test.py,sha256=SsMrRvLDYELyOAWLKISjkdEfrBwLYWRsT6D8WrsLM3Q,13533
|
|
1221
1221
|
cirq/work/zeros_sampler.py,sha256=Fs2JWwq0n9zv7_G5Rm-9vPeHUag7uctcMOHg0JTkZpc,2371
|
|
1222
1222
|
cirq/work/zeros_sampler_test.py,sha256=lQLgQDGBLtfImryys2HzQ2jOSGxHgc7-koVBUhv8qYk,3345
|
|
1223
|
-
cirq_core-1.6.0.
|
|
1224
|
-
cirq_core-1.6.0.
|
|
1225
|
-
cirq_core-1.6.0.
|
|
1226
|
-
cirq_core-1.6.0.
|
|
1227
|
-
cirq_core-1.6.0.
|
|
1223
|
+
cirq_core-1.6.0.dev20250523155818.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
|
|
1224
|
+
cirq_core-1.6.0.dev20250523155818.dist-info/METADATA,sha256=DxfVnOq9K86Aa6H5FaJiTb9KWNS6ojbgrCGUfys5ytE,4857
|
|
1225
|
+
cirq_core-1.6.0.dev20250523155818.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
|
|
1226
|
+
cirq_core-1.6.0.dev20250523155818.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
|
|
1227
|
+
cirq_core-1.6.0.dev20250523155818.dist-info/RECORD,,
|
{cirq_core-1.6.0.dev20250522221502.dist-info → cirq_core-1.6.0.dev20250523155818.dist-info}/WHEEL
RENAMED
|
File without changes
|
|
File without changes
|
|
File without changes
|