cirq-core 1.3.0.dev20231201164435__py3-none-any.whl → 1.4.0__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.
Files changed (157) hide show
  1. cirq/__init__.py +4 -0
  2. cirq/_compat.py +9 -11
  3. cirq/_compat_test.py +45 -56
  4. cirq/_version.py +31 -1
  5. cirq/_version_test.py +1 -1
  6. cirq/circuits/circuit.py +13 -8
  7. cirq/circuits/circuit_operation.py +2 -1
  8. cirq/circuits/circuit_test.py +2 -2
  9. cirq/circuits/frozen_circuit.py +3 -2
  10. cirq/circuits/moment.py +12 -10
  11. cirq/circuits/qasm_output.py +5 -1
  12. cirq/circuits/qasm_output_test.py +25 -10
  13. cirq/contrib/qcircuit/qcircuit_diagram_info.py +9 -7
  14. cirq/contrib/quimb/mps_simulator_test.py +1 -1
  15. cirq/contrib/quimb/state_vector.py +9 -2
  16. cirq/contrib/svg/svg.py +2 -1
  17. cirq/contrib/svg/svg_test.py +1 -0
  18. cirq/devices/grid_qubit.py +85 -32
  19. cirq/devices/grid_qubit_test.py +22 -4
  20. cirq/devices/line_qubit.py +74 -26
  21. cirq/devices/line_qubit_test.py +19 -0
  22. cirq/devices/noise_utils.py +33 -31
  23. cirq/devices/noise_utils_test.py +1 -84
  24. cirq/devices/superconducting_qubits_noise_properties.py +7 -6
  25. cirq/experiments/__init__.py +8 -0
  26. cirq/experiments/qubit_characterizations.py +288 -44
  27. cirq/experiments/qubit_characterizations_test.py +61 -7
  28. cirq/experiments/random_quantum_circuit_generation.py +1 -1
  29. cirq/experiments/single_qubit_readout_calibration.py +132 -6
  30. cirq/experiments/single_qubit_readout_calibration_test.py +3 -1
  31. cirq/experiments/t1_decay_experiment.py +14 -7
  32. cirq/experiments/t1_decay_experiment_test.py +14 -26
  33. cirq/experiments/two_qubit_xeb.py +483 -0
  34. cirq/experiments/two_qubit_xeb_test.py +304 -0
  35. cirq/json_resolver_cache.py +2 -0
  36. cirq/linalg/decompositions.py +11 -13
  37. cirq/linalg/decompositions_test.py +1 -3
  38. cirq/linalg/diagonalize.py +5 -4
  39. cirq/linalg/predicates.py +8 -6
  40. cirq/linalg/transformations.py +2 -1
  41. cirq/linalg/transformations_test.py +1 -1
  42. cirq/ops/__init__.py +2 -0
  43. cirq/ops/clifford_gate.py +59 -16
  44. cirq/ops/common_gates_test.py +1 -2
  45. cirq/ops/control_values.py +4 -3
  46. cirq/ops/controlled_gate_test.py +1 -3
  47. cirq/ops/gate_operation.py +10 -1
  48. cirq/ops/named_qubit.py +74 -28
  49. cirq/ops/named_qubit_test.py +19 -0
  50. cirq/ops/parity_gates.py +5 -0
  51. cirq/ops/parity_gates_test.py +2 -10
  52. cirq/ops/pauli_gates.py +5 -2
  53. cirq/ops/pauli_string.py +2 -2
  54. cirq/ops/permutation_gate.py +16 -18
  55. cirq/ops/phased_iswap_gate_test.py +1 -3
  56. cirq/ops/phased_x_gate.py +1 -1
  57. cirq/ops/phased_x_z_gate.py +17 -1
  58. cirq/ops/phased_x_z_gate_test.py +24 -0
  59. cirq/ops/qid_util.py +4 -8
  60. cirq/ops/qubit_manager.py +7 -4
  61. cirq/ops/qubit_manager_test.py +20 -0
  62. cirq/ops/raw_types.py +5 -2
  63. cirq/ops/raw_types_test.py +14 -15
  64. cirq/ops/uniform_superposition_gate.py +123 -0
  65. cirq/ops/uniform_superposition_gate_test.py +94 -0
  66. cirq/protocols/approximate_equality_protocol_test.py +2 -2
  67. cirq/protocols/circuit_diagram_info_protocol.py +6 -4
  68. cirq/protocols/commutes_protocol.py +2 -4
  69. cirq/protocols/decompose_protocol.py +7 -12
  70. cirq/protocols/decompose_protocol_test.py +7 -3
  71. cirq/protocols/has_stabilizer_effect_protocol.py +1 -5
  72. cirq/protocols/has_stabilizer_effect_protocol_test.py +13 -4
  73. cirq/protocols/json_serialization.py +51 -181
  74. cirq/protocols/json_serialization_test.py +13 -47
  75. cirq/protocols/json_test_data/CircuitOperation.json +131 -148
  76. cirq/protocols/json_test_data/CircuitOperation.json_inward +55 -0
  77. cirq/protocols/json_test_data/CircuitOperation.repr_inward +6 -0
  78. cirq/protocols/json_test_data/FrozenCircuit.json +196 -210
  79. cirq/protocols/json_test_data/FrozenCircuit.json_inward +35 -0
  80. cirq/protocols/json_test_data/FrozenCircuit.repr_inward +4 -0
  81. cirq/protocols/json_test_data/UniformSuperpositionGate.json +5 -0
  82. cirq/protocols/json_test_data/UniformSuperpositionGate.repr +1 -0
  83. cirq/protocols/json_test_data/cirq.MSGate.json +4 -0
  84. cirq/protocols/json_test_data/cirq.MSGate.repr +1 -0
  85. cirq/protocols/json_test_data/spec.py +2 -0
  86. cirq/protocols/pow_protocol_test.py +1 -3
  87. cirq/protocols/resolve_parameters.py +4 -2
  88. cirq/qis/__init__.py +10 -0
  89. cirq/qis/clifford_tableau.py +8 -2
  90. cirq/qis/noise_utils.py +123 -0
  91. cirq/qis/noise_utils_test.py +97 -0
  92. cirq/sim/classical_simulator.py +227 -87
  93. cirq/sim/classical_simulator_test.py +135 -0
  94. cirq/sim/clifford/clifford_simulator_test.py +4 -2
  95. cirq/sim/mux.py +5 -3
  96. cirq/sim/simulation_product_state.py +15 -10
  97. cirq/sim/simulation_state.py +1 -1
  98. cirq/sim/simulation_state_test.py +2 -2
  99. cirq/sim/simulator_base.py +3 -3
  100. cirq/sim/state_vector_simulation_state.py +4 -4
  101. cirq/sim/state_vector_simulator.py +17 -2
  102. cirq/study/__init__.py +1 -0
  103. cirq/study/result.py +14 -0
  104. cirq/study/result_test.py +6 -0
  105. cirq/study/sweeps.py +4 -2
  106. cirq/study/sweeps_test.py +8 -0
  107. cirq/testing/__init__.py +6 -1
  108. cirq/testing/_compat_test_data/__init__.py +3 -3
  109. cirq/testing/_compat_test_data/module_a/__init__.py +2 -2
  110. cirq/testing/circuit_compare.py +1 -1
  111. cirq/testing/consistent_qasm.py +6 -0
  112. cirq/testing/gate_features.py +10 -0
  113. cirq/testing/lin_alg_utils.py +5 -3
  114. cirq/transformers/__init__.py +15 -0
  115. cirq/transformers/analytical_decompositions/controlled_gate_decomposition.py +3 -1
  116. cirq/transformers/analytical_decompositions/two_qubit_to_cz.py +24 -0
  117. cirq/transformers/analytical_decompositions/two_qubit_to_cz_test.py +17 -0
  118. cirq/transformers/dynamical_decoupling.py +122 -0
  119. cirq/transformers/dynamical_decoupling_test.py +123 -0
  120. cirq/transformers/gauge_compiling/__init__.py +26 -0
  121. cirq/transformers/gauge_compiling/cz_gauge.py +46 -0
  122. cirq/transformers/gauge_compiling/cz_gauge_test.py +23 -0
  123. cirq/transformers/gauge_compiling/gauge_compiling.py +214 -0
  124. cirq/transformers/gauge_compiling/gauge_compiling_test.py +41 -0
  125. cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py +83 -0
  126. cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py +52 -0
  127. cirq/transformers/gauge_compiling/iswap_gauge.py +105 -0
  128. cirq/transformers/gauge_compiling/iswap_gauge_test.py +23 -0
  129. cirq/transformers/gauge_compiling/spin_inversion_gauge.py +33 -0
  130. cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py +37 -0
  131. cirq/transformers/gauge_compiling/sqrt_cz_gauge.py +64 -0
  132. cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py +27 -0
  133. cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py +94 -0
  134. cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py +22 -0
  135. cirq/transformers/heuristic_decompositions/two_qubit_gate_tabulation.py +1 -0
  136. cirq/transformers/merge_k_qubit_gates_test.py +23 -23
  137. cirq/transformers/merge_single_qubit_gates_test.py +14 -14
  138. cirq/transformers/optimize_for_target_gateset.py +39 -17
  139. cirq/transformers/optimize_for_target_gateset_test.py +189 -39
  140. cirq/transformers/qubit_management_transformers.py +1 -1
  141. cirq/transformers/routing/visualize_routed_circuit_test.py +17 -17
  142. cirq/transformers/stratify_test.py +13 -13
  143. cirq/transformers/target_gatesets/compilation_target_gateset.py +26 -2
  144. cirq/transformers/target_gatesets/compilation_target_gateset_test.py +16 -16
  145. cirq/transformers/target_gatesets/cz_gateset.py +4 -0
  146. cirq/transformers/transformer_api.py +1 -2
  147. cirq/transformers/transformer_primitives.py +15 -14
  148. cirq/transformers/transformer_primitives_test.py +99 -72
  149. cirq/value/classical_data.py +6 -6
  150. cirq/value/value_equality_attr.py +4 -0
  151. cirq/work/sampler.py +3 -4
  152. cirq/work/sampler_test.py +25 -0
  153. {cirq_core-1.3.0.dev20231201164435.dist-info → cirq_core-1.4.0.dist-info}/METADATA +10 -19
  154. {cirq_core-1.3.0.dev20231201164435.dist-info → cirq_core-1.4.0.dist-info}/RECORD +157 -130
  155. {cirq_core-1.3.0.dev20231201164435.dist-info → cirq_core-1.4.0.dist-info}/WHEEL +1 -1
  156. {cirq_core-1.3.0.dev20231201164435.dist-info → cirq_core-1.4.0.dist-info}/LICENSE +0 -0
  157. {cirq_core-1.3.0.dev20231201164435.dist-info → cirq_core-1.4.0.dist-info}/top_level.txt +0 -0
@@ -1,10 +1,10 @@
1
- {
2
- "cirq_type": "_ContextualSerialization",
3
- "object_dag": [
4
- {
5
- "cirq_type": "_SerializedContext",
6
- "key": 1,
7
- "obj": {
1
+ [
2
+ {
3
+ "cirq_type": "CircuitOperation",
4
+ "circuit": {
5
+ "cirq_type": "VAL",
6
+ "key": 0,
7
+ "val": {
8
8
  "cirq_type": "FrozenCircuit",
9
9
  "moments": [
10
10
  {
@@ -121,10 +121,26 @@
121
121
  ]
122
122
  }
123
123
  },
124
- {
125
- "cirq_type": "_SerializedContext",
126
- "key": 2,
127
- "obj": {
124
+ "repetitions": 1,
125
+ "qubit_map": [],
126
+ "measurement_key_map": {
127
+ "0,1,2,3,4": "mixed_state"
128
+ },
129
+ "param_resolver": {
130
+ "cirq_type": "ParamResolver",
131
+ "param_dict": []
132
+ },
133
+ "parent_path": [],
134
+ "repetition_ids": [
135
+ "0"
136
+ ]
137
+ },
138
+ {
139
+ "cirq_type": "CircuitOperation",
140
+ "circuit": {
141
+ "cirq_type": "VAL",
142
+ "key": 1,
143
+ "val": {
128
144
  "cirq_type": "FrozenCircuit",
129
145
  "moments": [
130
146
  {
@@ -149,10 +165,66 @@
149
165
  ]
150
166
  }
151
167
  },
152
- {
153
- "cirq_type": "_SerializedContext",
154
- "key": 3,
155
- "obj": {
168
+ "repetitions": -2,
169
+ "qubit_map": [
170
+ [
171
+ {
172
+ "cirq_type": "LineQubit",
173
+ "x": 0
174
+ },
175
+ {
176
+ "cirq_type": "LineQubit",
177
+ "x": 1
178
+ }
179
+ ]
180
+ ],
181
+ "measurement_key_map": {},
182
+ "param_resolver": {
183
+ "cirq_type": "ParamResolver",
184
+ "param_dict": []
185
+ },
186
+ "parent_path": [],
187
+ "repetition_ids": [
188
+ "a",
189
+ "b"
190
+ ]
191
+ },
192
+ {
193
+ "cirq_type": "CircuitOperation",
194
+ "circuit": {
195
+ "cirq_type": "REF",
196
+ "key": 1
197
+ },
198
+ "repetitions": -2,
199
+ "qubit_map": [
200
+ [
201
+ {
202
+ "cirq_type": "LineQubit",
203
+ "x": 0
204
+ },
205
+ {
206
+ "cirq_type": "LineQubit",
207
+ "x": 1
208
+ }
209
+ ]
210
+ ],
211
+ "measurement_key_map": {},
212
+ "param_resolver": {
213
+ "cirq_type": "ParamResolver",
214
+ "param_dict": []
215
+ },
216
+ "parent_path": ["outer", "inner"],
217
+ "repetition_ids": [
218
+ "a",
219
+ "b"
220
+ ]
221
+ },
222
+ {
223
+ "cirq_type": "CircuitOperation",
224
+ "circuit": {
225
+ "cirq_type": "VAL",
226
+ "key": 2,
227
+ "val": {
156
228
  "cirq_type": "FrozenCircuit",
157
229
  "moments": [
158
230
  {
@@ -180,138 +252,49 @@
180
252
  ]
181
253
  }
182
254
  },
183
- [
184
- {
185
- "cirq_type": "CircuitOperation",
186
- "circuit": {
187
- "cirq_type": "_SerializedKey",
188
- "key": 1
189
- },
190
- "repetitions": 1,
191
- "qubit_map": [],
192
- "measurement_key_map": {
193
- "0,1,2,3,4": "mixed_state"
194
- },
195
- "param_resolver": {
196
- "cirq_type": "ParamResolver",
197
- "param_dict": []
198
- },
199
- "parent_path": [],
200
- "repetition_ids": [
201
- "0"
202
- ]
203
- },
204
- {
205
- "cirq_type": "CircuitOperation",
206
- "circuit": {
207
- "cirq_type": "_SerializedKey",
208
- "key": 2
209
- },
210
- "repetitions": -2,
211
- "qubit_map": [
212
- [
213
- {
214
- "cirq_type": "LineQubit",
215
- "x": 0
216
- },
217
- {
218
- "cirq_type": "LineQubit",
219
- "x": 1
220
- }
221
- ]
222
- ],
223
- "measurement_key_map": {},
224
- "param_resolver": {
225
- "cirq_type": "ParamResolver",
226
- "param_dict": []
227
- },
228
- "parent_path": [],
229
- "repetition_ids": [
230
- "a",
231
- "b"
232
- ]
233
- },
234
- {
235
- "cirq_type": "CircuitOperation",
236
- "circuit": {
237
- "cirq_type": "_SerializedKey",
238
- "key": 2
239
- },
240
- "repetitions": -2,
241
- "qubit_map": [
242
- [
243
- {
244
- "cirq_type": "LineQubit",
245
- "x": 0
246
- },
247
- {
248
- "cirq_type": "LineQubit",
249
- "x": 1
250
- }
251
- ]
252
- ],
253
- "measurement_key_map": {},
254
- "param_resolver": {
255
- "cirq_type": "ParamResolver",
256
- "param_dict": []
257
- },
258
- "parent_path": ["outer", "inner"],
259
- "repetition_ids": [
260
- "a",
261
- "b"
255
+ "repetitions": 1,
256
+ "qubit_map": [],
257
+ "measurement_key_map": {},
258
+ "param_resolver": {
259
+ "cirq_type": "ParamResolver",
260
+ "param_dict": [
261
+ [
262
+ {
263
+ "cirq_type": "sympy.Symbol",
264
+ "name": "theta"
265
+ },
266
+ 1.5
262
267
  ]
268
+ ]
269
+ },
270
+ "parent_path": [],
271
+ "repetition_ids": null,
272
+ "use_repetition_ids": false
273
+ },
274
+ {
275
+ "cirq_type": "CircuitOperation",
276
+ "circuit": {
277
+ "cirq_type": "REF",
278
+ "key": 0
279
+ },
280
+ "repetitions": 1,
281
+ "qubit_map": [],
282
+ "measurement_key_map": {},
283
+ "param_resolver": {
284
+ "cirq_type": "ParamResolver",
285
+ "param_dict": []
286
+ },
287
+ "parent_path": [],
288
+ "repetition_ids": null,
289
+ "use_repetition_ids": false,
290
+ "repeat_until": {
291
+ "cirq_type": "KeyCondition",
292
+ "key": {
293
+ "cirq_type": "MeasurementKey",
294
+ "name": "0,1,2,3,4",
295
+ "path": []
263
296
  },
264
- {
265
- "cirq_type": "CircuitOperation",
266
- "circuit": {
267
- "cirq_type": "_SerializedKey",
268
- "key": 3
269
- },
270
- "repetitions": 1,
271
- "qubit_map": [],
272
- "measurement_key_map": {},
273
- "param_resolver": {
274
- "cirq_type": "ParamResolver",
275
- "param_dict": [
276
- [
277
- {
278
- "cirq_type": "sympy.Symbol",
279
- "name": "theta"
280
- },
281
- 1.5
282
- ]
283
- ]
284
- },
285
- "parent_path": [],
286
- "repetition_ids": null,
287
- "use_repetition_ids": false
288
- },
289
- {
290
- "cirq_type": "CircuitOperation",
291
- "circuit": {
292
- "cirq_type": "_SerializedKey",
293
- "key": 1
294
- },
295
- "repetitions": 1,
296
- "qubit_map": [],
297
- "measurement_key_map": {},
298
- "param_resolver": {
299
- "cirq_type": "ParamResolver",
300
- "param_dict": []
301
- },
302
- "parent_path": [],
303
- "repetition_ids": null,
304
- "use_repetition_ids": false,
305
- "repeat_until": {
306
- "cirq_type": "KeyCondition",
307
- "key": {
308
- "cirq_type": "MeasurementKey",
309
- "name": "0,1,2,3,4",
310
- "path": []
311
- },
312
- "index": -1
313
- }
314
- }
315
- ]
316
- ]
317
- }
297
+ "index": -1
298
+ }
299
+ }
300
+ ]
@@ -189,6 +189,37 @@
189
189
  }
190
190
  }
191
191
  },
192
+ {
193
+ "cirq_type": "_SerializedContext",
194
+ "key": 4,
195
+ "obj": {
196
+ "cirq_type": "FrozenCircuit",
197
+ "moments": [
198
+ {
199
+ "cirq_type": "Moment",
200
+ "operations": [
201
+ {
202
+ "cirq_type": "GateOperation",
203
+ "gate": {
204
+ "cirq_type": "XPowGate",
205
+ "exponent": {
206
+ "cirq_type": "sympy.Symbol",
207
+ "name": "theta"
208
+ },
209
+ "global_shift": 0.0
210
+ },
211
+ "qubits": [
212
+ {
213
+ "cirq_type": "LineQubit",
214
+ "x": 0
215
+ }
216
+ ]
217
+ }
218
+ ]
219
+ }
220
+ ]
221
+ }
222
+ },
192
223
  [
193
224
  {
194
225
  "cirq_type": "CircuitOperation",
@@ -261,6 +292,30 @@
261
292
  },
262
293
  "parent_path": [],
263
294
  "repetition_ids": null
295
+ },
296
+ {
297
+ "cirq_type": "CircuitOperation",
298
+ "circuit": {
299
+ "cirq_type": "_SerializedKey",
300
+ "key": 4
301
+ },
302
+ "repetitions": 1,
303
+ "qubit_map": [],
304
+ "measurement_key_map": {},
305
+ "param_resolver": {
306
+ "cirq_type": "ParamResolver",
307
+ "param_dict": [
308
+ [
309
+ {
310
+ "cirq_type": "sympy.Symbol",
311
+ "name": "theta"
312
+ },
313
+ 1.5
314
+ ]
315
+ ]
316
+ },
317
+ "parent_path": [],
318
+ "repetition_ids": null
264
319
  }
265
320
  ]
266
321
  ]
@@ -25,4 +25,10 @@ cirq.CircuitOperation(circuit=cirq.FrozenCircuit([
25
25
  (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)),
26
26
  ),
27
27
  ]),
28
+ param_resolver={sympy.Symbol('theta'): 1.5}),
29
+ cirq.CircuitOperation(circuit=cirq.FrozenCircuit([
30
+ cirq.Moment(
31
+ (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)),
32
+ ),
33
+ ]),
28
34
  param_resolver={sympy.Symbol('theta'): 1.5})]