cirq-core 1.3.0.dev20231201141002__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.dev20231201141002.dist-info → cirq_core-1.4.0.dist-info}/METADATA +10 -19
  154. {cirq_core-1.3.0.dev20231201141002.dist-info → cirq_core-1.4.0.dist-info}/RECORD +157 -130
  155. {cirq_core-1.3.0.dev20231201141002.dist-info → cirq_core-1.4.0.dist-info}/WHEEL +1 -1
  156. {cirq_core-1.3.0.dev20231201141002.dist-info → cirq_core-1.4.0.dist-info}/LICENSE +0 -0
  157. {cirq_core-1.3.0.dev20231201141002.dist-info → cirq_core-1.4.0.dist-info}/top_level.txt +0 -0
@@ -1,222 +1,208 @@
1
- {
2
- "cirq_type": "_ContextualSerialization",
3
- "object_dag": [
4
- {
5
- "cirq_type": "_SerializedContext",
6
- "key": 1,
7
- "obj": {
8
- "cirq_type": "FrozenCircuit",
9
- "moments": [ { "cirq_type": "Moment",
10
- "operations": [
11
- {
12
- "cirq_type": "GateOperation",
13
- "gate": { "cirq_type": "HPowGate",
1
+ [
2
+ {
3
+ "cirq_type": "VAL",
4
+ "key": 0,
5
+ "val": {
6
+ "cirq_type": "FrozenCircuit",
7
+ "moments": [
8
+ {
9
+ "cirq_type": "Moment",
10
+ "operations": [
11
+ {
12
+ "cirq_type": "GateOperation",
13
+ "gate": {
14
+ "cirq_type": "HPowGate",
14
15
  "exponent": 1.0,
15
16
  "global_shift": 0.0
16
17
  },
17
- "qubits": [
18
- {
19
- "cirq_type": "LineQubit",
20
- "x": 0
21
- }
22
- ]
18
+ "qubits": [
19
+ {
20
+ "cirq_type": "LineQubit",
21
+ "x": 0
22
+ }
23
+ ]
24
+ },
25
+ {
26
+ "cirq_type": "GateOperation",
27
+ "gate": {
28
+ "cirq_type": "HPowGate",
29
+ "exponent": 1.0,
30
+ "global_shift": 0.0
23
31
  },
24
- {
25
- "cirq_type": "GateOperation",
26
- "gate": {
27
- "cirq_type": "HPowGate",
28
- "exponent": 1.0,
29
- "global_shift": 0.0
30
- },
31
- "qubits": [
32
- {
33
- "cirq_type": "LineQubit",
34
- "x": 1
35
- }
36
- ]
32
+ "qubits": [
33
+ {
34
+ "cirq_type": "LineQubit",
35
+ "x": 1
36
+ }
37
+ ]
38
+ },
39
+ {
40
+ "cirq_type": "GateOperation",
41
+ "gate": {
42
+ "cirq_type": "HPowGate",
43
+ "exponent": 1.0,
44
+ "global_shift": 0.0
37
45
  },
38
- {
39
- "cirq_type": "GateOperation",
40
- "gate": {
41
- "cirq_type": "HPowGate",
42
- "exponent": 1.0,
43
- "global_shift": 0.0
44
- },
45
- "qubits": [
46
- {
47
- "cirq_type": "LineQubit",
48
- "x": 2
49
- }
50
- ]
46
+ "qubits": [
47
+ {
48
+ "cirq_type": "LineQubit",
49
+ "x": 2
50
+ }
51
+ ]
52
+ },
53
+ {
54
+ "cirq_type": "GateOperation",
55
+ "gate": {
56
+ "cirq_type": "HPowGate",
57
+ "exponent": 1.0,
58
+ "global_shift": 0.0
51
59
  },
52
- {
53
- "cirq_type": "GateOperation",
54
- "gate": {
55
- "cirq_type": "HPowGate",
56
- "exponent": 1.0,
57
- "global_shift": 0.0
58
- },
59
- "qubits": [
60
- {
61
- "cirq_type": "LineQubit",
62
- "x": 3
63
- }
64
- ]
60
+ "qubits": [
61
+ {
62
+ "cirq_type": "LineQubit",
63
+ "x": 3
64
+ }
65
+ ]
66
+ },
67
+ {
68
+ "cirq_type": "GateOperation",
69
+ "gate": {
70
+ "cirq_type": "HPowGate",
71
+ "exponent": 1.0,
72
+ "global_shift": 0.0
65
73
  },
66
- {
67
- "cirq_type": "GateOperation",
68
- "gate": {
69
- "cirq_type": "HPowGate",
70
- "exponent": 1.0,
71
- "global_shift": 0.0
74
+ "qubits": [
75
+ {
76
+ "cirq_type": "LineQubit",
77
+ "x": 4
78
+ }
79
+ ]
80
+ }
81
+ ]
82
+ },
83
+ {
84
+ "cirq_type": "Moment",
85
+ "operations": [
86
+ {
87
+ "cirq_type": "GateOperation",
88
+ "gate": {
89
+ "cirq_type": "MeasurementGate",
90
+ "num_qubits": 5,
91
+ "key": "0,1,2,3,4",
92
+ "invert_mask": []
93
+ },
94
+ "qubits": [
95
+ {
96
+ "cirq_type": "LineQubit",
97
+ "x": 0
72
98
  },
73
- "qubits": [
74
- {
75
- "cirq_type": "LineQubit",
76
- "x": 4
77
- }
78
- ]
79
- }
80
- ]
81
- },
82
- {
83
- "cirq_type": "Moment",
84
- "operations": [
85
- {
86
- "cirq_type": "GateOperation",
87
- "gate": {
88
- "cirq_type": "MeasurementGate",
89
- "num_qubits": 5,
90
- "key": "0,1,2,3,4",
91
- "invert_mask": []
99
+ {
100
+ "cirq_type": "LineQubit",
101
+ "x": 1
92
102
  },
93
- "qubits": [
94
- {
95
- "cirq_type": "LineQubit",
96
- "x": 0
97
- },
98
- {
99
- "cirq_type": "LineQubit",
100
- "x": 1
101
- },
102
- {
103
- "cirq_type": "LineQubit",
104
- "x": 2
105
- },
106
- {
107
- "cirq_type": "LineQubit",
108
- "x": 3
109
- },
110
- {
111
- "cirq_type": "LineQubit",
112
- "x": 4
113
- }
114
- ]
115
- }
116
- ]
117
- }
118
- ]
119
- }
120
- },
121
- {
122
- "cirq_type": "_SerializedContext",
123
- "key": 2,
124
- "obj": {
125
- "cirq_type": "FrozenCircuit",
126
- "moments": [
127
- {
128
- "cirq_type": "Moment",
129
- "operations": [
130
- {
131
- "cirq_type": "GateOperation",
132
- "gate": {
133
- "cirq_type": "CCXPowGate",
134
- "exponent": 1.0,
135
- "global_shift": 0.0
103
+ {
104
+ "cirq_type": "LineQubit",
105
+ "x": 2
136
106
  },
137
- "qubits": [
138
- {
139
- "cirq_type": "LineQubit",
140
- "x": 0
141
- },
142
- {
143
- "cirq_type": "LineQubit",
144
- "x": 1
145
- },
146
- {
147
- "cirq_type": "LineQubit",
148
- "x": 2
149
- }
150
- ]
151
- }
152
- ]
153
- },
154
- {
155
- "cirq_type": "Moment",
156
- "operations": [
157
- {
158
- "cirq_type": "GateOperation",
159
- "gate": {
160
- "cirq_type": "XPowGate",
161
- "exponent": 0.123,
162
- "global_shift": 0.0
107
+ {
108
+ "cirq_type": "LineQubit",
109
+ "x": 3
163
110
  },
164
- "qubits": [
165
- {
166
- "cirq_type": "LineQubit",
167
- "x": 0
168
- }
169
- ]
170
- }
171
- ]
172
- }
173
- ]
174
- }
175
- },
176
- {
177
- "cirq_type": "_SerializedContext",
178
- "key": 3,
179
- "obj": {
180
- "cirq_type": "FrozenCircuit",
181
- "moments": [
182
- {
183
- "cirq_type": "Moment",
184
- "operations": [
185
- {
186
- "cirq_type": "GateOperation",
187
- "gate": {
188
- "cirq_type": "XPowGate",
189
- "exponent": {
190
- "cirq_type": "sympy.Symbol",
191
- "name": "theta"
192
- },
193
- "global_shift": 0.0
111
+ {
112
+ "cirq_type": "LineQubit",
113
+ "x": 4
114
+ }
115
+ ]
116
+ }
117
+ ]
118
+ }
119
+ ]
120
+ }
121
+ },
122
+ {
123
+ "cirq_type": "VAL",
124
+ "key": 1,
125
+ "val": {
126
+ "cirq_type": "FrozenCircuit",
127
+ "moments": [
128
+ {
129
+ "cirq_type": "Moment",
130
+ "operations": [
131
+ {
132
+ "cirq_type": "GateOperation",
133
+ "gate": {
134
+ "cirq_type": "CCXPowGate",
135
+ "exponent": 1.0,
136
+ "global_shift": 0.0
137
+ },
138
+ "qubits": [
139
+ {
140
+ "cirq_type": "LineQubit",
141
+ "x": 0
142
+ },
143
+ {
144
+ "cirq_type": "LineQubit",
145
+ "x": 1
194
146
  },
195
- "qubits": [
196
- {
197
- "cirq_type": "LineQubit",
198
- "x": 0
199
- }
200
- ]
201
- }
202
- ]
203
- }
204
- ]
205
- }
206
- },
207
- [
208
- {
209
- "cirq_type": "_SerializedKey",
210
- "key": 1
211
- },
212
- {
213
- "cirq_type": "_SerializedKey",
214
- "key": 2
215
- },
216
- {
217
- "cirq_type": "_SerializedKey",
218
- "key": 3
219
- }
220
- ]
221
- ]
222
- }
147
+ {
148
+ "cirq_type": "LineQubit",
149
+ "x": 2
150
+ }
151
+ ]
152
+ }
153
+ ]
154
+ },
155
+ {
156
+ "cirq_type": "Moment",
157
+ "operations": [
158
+ {
159
+ "cirq_type": "GateOperation",
160
+ "gate": {
161
+ "cirq_type": "XPowGate",
162
+ "exponent": 0.123,
163
+ "global_shift": 0.0
164
+ },
165
+ "qubits": [
166
+ {
167
+ "cirq_type": "LineQubit",
168
+ "x": 0
169
+ }
170
+ ]
171
+ }
172
+ ]
173
+ }
174
+ ]
175
+ }
176
+ },
177
+ {
178
+ "cirq_type": "VAL",
179
+ "key": 2,
180
+ "val": {
181
+ "cirq_type": "FrozenCircuit",
182
+ "moments": [
183
+ {
184
+ "cirq_type": "Moment",
185
+ "operations": [
186
+ {
187
+ "cirq_type": "GateOperation",
188
+ "gate": {
189
+ "cirq_type": "XPowGate",
190
+ "exponent": {
191
+ "cirq_type": "sympy.Symbol",
192
+ "name": "theta"
193
+ },
194
+ "global_shift": 0.0
195
+ },
196
+ "qubits": [
197
+ {
198
+ "cirq_type": "LineQubit",
199
+ "x": 0
200
+ }
201
+ ]
202
+ }
203
+ ]
204
+ }
205
+ ]
206
+ }
207
+ }
208
+ ]
@@ -213,6 +213,37 @@
213
213
  }
214
214
  }
215
215
  },
216
+ {
217
+ "cirq_type": "_SerializedContext",
218
+ "key": 4,
219
+ "obj": {
220
+ "cirq_type": "FrozenCircuit",
221
+ "moments": [
222
+ {
223
+ "cirq_type": "Moment",
224
+ "operations": [
225
+ {
226
+ "cirq_type": "GateOperation",
227
+ "gate": {
228
+ "cirq_type": "XPowGate",
229
+ "exponent": {
230
+ "cirq_type": "sympy.Symbol",
231
+ "name": "theta"
232
+ },
233
+ "global_shift": 0.0
234
+ },
235
+ "qubits": [
236
+ {
237
+ "cirq_type": "LineQubit",
238
+ "x": 0
239
+ }
240
+ ]
241
+ }
242
+ ]
243
+ }
244
+ ]
245
+ }
246
+ },
216
247
  [
217
248
  {
218
249
  "cirq_type": "_SerializedKey",
@@ -225,6 +256,10 @@
225
256
  {
226
257
  "cirq_type": "_SerializedKey",
227
258
  "key": 3
259
+ },
260
+ {
261
+ "cirq_type": "_SerializedKey",
262
+ "key": 4
228
263
  }
229
264
  ]
230
265
  ]
@@ -20,4 +20,8 @@
20
20
  cirq.Moment(
21
21
  (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)),
22
22
  ),
23
+ ]), cirq.FrozenCircuit([
24
+ cirq.Moment(
25
+ (cirq.X**sympy.Symbol('theta')).on(cirq.LineQubit(0)),
26
+ ),
23
27
  ])]
@@ -0,0 +1,5 @@
1
+ {
2
+ "cirq_type": "UniformSuperpositionGate",
3
+ "m_value": 7,
4
+ "num_qubits": 3
5
+ }
@@ -0,0 +1 @@
1
+ cirq.UniformSuperpositionGate(m_value=7, num_qubits=3)
@@ -0,0 +1,4 @@
1
+ {
2
+ "cirq_type": "cirq.MSGate",
3
+ "rads": 1.5707963267948966
4
+ }
@@ -0,0 +1 @@
1
+ cirq.ms(np.pi/2)
@@ -22,6 +22,7 @@ TestSpec = ModuleJsonTestSpec(
22
22
  name="cirq",
23
23
  packages=[cirq, cirq.work],
24
24
  test_data_path=pathlib.Path(__file__).parent,
25
+ custom_class_name_to_cirq_type={"MSGate": "cirq.MSGate"},
25
26
  resolver_cache=_class_resolver_dictionary(),
26
27
  not_yet_serializable=[
27
28
  'Alignment',
@@ -108,6 +109,7 @@ TestSpec = ModuleJsonTestSpec(
108
109
  'StateVectorStepResult',
109
110
  'StepResultBase',
110
111
  'UnitSweep',
112
+ 'UNIT_SWEEP',
111
113
  'NamedTopology',
112
114
  # protocols:
113
115
  'HasJSONNamespace',
@@ -49,6 +49,4 @@ def test_pow_error():
49
49
 
50
50
  @pytest.mark.parametrize('val,exponent,out', ((ReturnsExponent(), 2, 2), (1, 2, 1), (2, 3, 8)))
51
51
  def test_pow_with_result(val, exponent, out):
52
- assert (
53
- cirq.pow(val, exponent) == cirq.pow(val, exponent, default=None) == val**exponent == out
54
- )
52
+ assert cirq.pow(val, exponent) == cirq.pow(val, exponent, default=None) == val**exponent == out
@@ -178,8 +178,10 @@ def resolve_parameters(
178
178
  if isinstance(val, (list, tuple)):
179
179
  return cast(T, type(val)(resolve_parameters(e, param_resolver, recursive) for e in val))
180
180
 
181
- is_parameterized = getattr(val, '_is_parameterized_', None)
182
- if is_parameterized is not None and not is_parameterized():
181
+ is_parameterized = (
182
+ val._is_parameterized_() if hasattr(val, '_is_parameterized_') else NotImplemented
183
+ )
184
+ if is_parameterized is not NotImplemented and not is_parameterized:
183
185
  return val
184
186
 
185
187
  getter = getattr(val, '_resolve_parameters_', None)
cirq/qis/__init__.py CHANGED
@@ -50,3 +50,13 @@ from cirq.qis.states import (
50
50
  validate_qid_shape,
51
51
  validate_normalized_state_vector,
52
52
  )
53
+
54
+ from cirq.qis.noise_utils import (
55
+ decay_constant_to_xeb_fidelity,
56
+ decay_constant_to_pauli_error,
57
+ pauli_error_to_decay_constant,
58
+ xeb_fidelity_to_decay_constant,
59
+ pauli_error_from_t1,
60
+ average_error,
61
+ decoherence_pauli_error,
62
+ )
@@ -17,7 +17,7 @@ from typing import Any, Dict, List, Optional, Sequence, TYPE_CHECKING
17
17
  import numpy as np
18
18
 
19
19
  from cirq import protocols
20
- from cirq._compat import proper_repr
20
+ from cirq._compat import proper_repr, cached_method
21
21
  from cirq.qis import quantum_state_representation
22
22
  from cirq.value import big_endian_int_to_digits, linear_dict, random_state
23
23
 
@@ -129,7 +129,9 @@ class StabilizerState(
129
129
 
130
130
  class CliffordTableau(StabilizerState):
131
131
  """Tableau representation of a stabilizer state
132
- (based on Aaronson and Gottesman 2006).
132
+
133
+ References:
134
+ - [Aaronson and Gottesman](https://arxiv.org/abs/quant-ph/0406196)
133
135
 
134
136
  The tableau stores the stabilizer generators of
135
137
  the state using three binary arrays: xs, zs, and rs.
@@ -652,3 +654,7 @@ class CliffordTableau(StabilizerState):
652
654
  self, axes: Sequence[int], seed: 'cirq.RANDOM_STATE_OR_SEED_LIKE' = None
653
655
  ) -> List[int]:
654
656
  return [self._measure(axis, random_state.parse_random_state(seed)) for axis in axes]
657
+
658
+ @cached_method
659
+ def __hash__(self) -> int:
660
+ return hash(self.matrix().tobytes() + self.rs.tobytes())