cirq-core 1.5.0.dev20250404223605__py3-none-any.whl → 1.5.0.dev20250405043305__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 CHANGED
@@ -28,4 +28,4 @@ if sys.version_info < (3, 10, 0): # pragma: no cover
28
28
  'of cirq (e.g. "python -m pip install cirq==1.1.*")'
29
29
  )
30
30
 
31
- __version__ = "1.5.0.dev20250404223605"
31
+ __version__ = "1.5.0.dev20250405043305"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version():
6
- assert cirq.__version__ == "1.5.0.dev20250404223605"
6
+ assert cirq.__version__ == "1.5.0.dev20250405043305"
cirq/linalg/__init__.py CHANGED
@@ -82,9 +82,11 @@ from cirq.linalg.tolerance import (
82
82
  from cirq.linalg.transformations import (
83
83
  apply_matrix_to_slices as apply_matrix_to_slices,
84
84
  density_matrix_kronecker_product as density_matrix_kronecker_product,
85
+ can_numpy_support_shape as can_numpy_support_shape,
85
86
  match_global_phase as match_global_phase,
86
87
  partial_trace as partial_trace,
87
88
  partial_trace_of_state_vector_as_mixture as partial_trace_of_state_vector_as_mixture,
89
+ phase_delta as phase_delta,
88
90
  reflection_matrix_pow as reflection_matrix_pow,
89
91
  state_vector_kronecker_product as state_vector_kronecker_product,
90
92
  sub_state_vector as sub_state_vector,
@@ -92,5 +94,4 @@ from cirq.linalg.transformations import (
92
94
  targeted_left_multiply as targeted_left_multiply,
93
95
  to_special as to_special,
94
96
  transpose_flattened_array as transpose_flattened_array,
95
- can_numpy_support_shape as can_numpy_support_shape,
96
97
  )
@@ -814,3 +814,17 @@ def _can_numpy_support_dims(num_dims: int) -> bool:
814
814
  def can_numpy_support_shape(shape: Sequence[int]) -> bool:
815
815
  """Returns whether numpy supports the given shape or not numpy/numpy#5744."""
816
816
  return min(shape, default=0) >= 0 and _can_numpy_support_dims(len(shape))
817
+
818
+
819
+ def phase_delta(u1: np.ndarray, u2: np.ndarray) -> complex:
820
+ """Calculates the phase delta of two unitaries.
821
+
822
+ The delta is from u1 to u2. i.e. u1 * phase_delta(u1, u2) == u2.
823
+
824
+ Assumes but does not verify that inputs are valid unitaries and differ only
825
+ by phase.
826
+ """
827
+ # All cells will have the same phase difference. Just choose the cell with the largest
828
+ # absolute value, to minimize rounding error.
829
+ max_index = np.unravel_index(np.abs(u1).argmax(), u1.shape)
830
+ return u2[max_index] / u1[max_index]
@@ -653,3 +653,11 @@ def test_transpose_flattened_array(num_dimensions):
653
653
  @pytest.mark.parametrize('shape, result', [((), True), (30 * (1,), True), ((-3, 1, -1), False)])
654
654
  def test_can_numpy_support_shape(shape: tuple[int, ...], result: bool) -> None:
655
655
  assert linalg.can_numpy_support_shape(shape) is result
656
+
657
+
658
+ @pytest.mark.parametrize('coeff', [1, 1j, -1, -1j, 1j**0.5, 1j**0.3])
659
+ def test_phase_delta(coeff):
660
+ u1 = cirq.testing.random_unitary(4)
661
+ u2 = u1 * coeff
662
+ np.testing.assert_almost_equal(linalg.phase_delta(u1, u2), coeff)
663
+ np.testing.assert_almost_equal(u1 * linalg.phase_delta(u1, u2), u2)
cirq/ops/common_gates.py CHANGED
@@ -326,12 +326,6 @@ class XPowGate(eigen_gate.EigenGate):
326
326
  d['dimension'] = self.dimension
327
327
  return d
328
328
 
329
- def _value_equality_values_(self):
330
- return (*super()._value_equality_values_(), self._dimension)
331
-
332
- def _value_equality_approximate_values_(self):
333
- return (*super()._value_equality_approximate_values_(), self._dimension)
334
-
335
329
 
336
330
  class Rx(XPowGate):
337
331
  r"""A gate with matrix $e^{-i X t/2}$ that rotates around the X axis of the Bloch sphere by $t$.
@@ -862,12 +856,6 @@ class ZPowGate(eigen_gate.EigenGate):
862
856
  d['dimension'] = self.dimension
863
857
  return d
864
858
 
865
- def _value_equality_values_(self):
866
- return (*super()._value_equality_values_(), self._dimension)
867
-
868
- def _value_equality_approximate_values_(self):
869
- return (*super()._value_equality_approximate_values_(), self._dimension)
870
-
871
859
 
872
860
  class Rz(ZPowGate):
873
861
  r"""A gate with matrix $e^{-i Z t/2}$ that rotates around the Z axis of the Bloch sphere by $t$.
@@ -245,11 +245,12 @@ def test_rot_gates_eq():
245
245
  eq.add_equality_group(cirq.YPowGate(), cirq.YPowGate(exponent=1), cirq.Y)
246
246
  eq.add_equality_group(cirq.ZPowGate(), cirq.ZPowGate(exponent=1), cirq.Z)
247
247
  eq.add_equality_group(
248
- cirq.ZPowGate(exponent=1, global_shift=-0.5), cirq.ZPowGate(exponent=5, global_shift=-0.5)
248
+ cirq.ZPowGate(exponent=1, global_shift=-0.5),
249
+ cirq.ZPowGate(exponent=5, global_shift=-0.5),
250
+ cirq.ZPowGate(exponent=5, global_shift=-0.1),
249
251
  )
250
252
  eq.add_equality_group(cirq.ZPowGate(exponent=3, global_shift=-0.5))
251
253
  eq.add_equality_group(cirq.ZPowGate(exponent=1, global_shift=-0.1))
252
- eq.add_equality_group(cirq.ZPowGate(exponent=5, global_shift=-0.1))
253
254
  eq.add_equality_group(
254
255
  cirq.CNotPowGate(), cirq.CXPowGate(), cirq.CNotPowGate(exponent=1), cirq.CNOT
255
256
  )
@@ -34,7 +34,6 @@ from cirq.ops import (
34
34
  controlled_operation as cop,
35
35
  diagonal_gate as dg,
36
36
  global_phase_op as gp,
37
- matrix_gates,
38
37
  op_tree,
39
38
  raw_types,
40
39
  )
@@ -220,12 +219,6 @@ class ControlledGate(raw_types.Gate):
220
219
  control_qid_shape=self.control_qid_shape,
221
220
  ).on(*control_qubits)
222
221
  return [result, controlled_phase_op]
223
-
224
- if isinstance(self.sub_gate, matrix_gates.MatrixGate):
225
- # Default decompositions of 2/3 qubit `cirq.MatrixGate` ignores global phase, which is
226
- # local phase in the controlled variant and hence cannot be ignored.
227
- return NotImplemented
228
-
229
222
  result = protocols.decompose_once_with_qubits(
230
223
  self.sub_gate,
231
224
  qubits[self.num_controls() :],
@@ -431,10 +431,23 @@ def test_controlled_gate_is_consistent(gate: cirq.Gate, should_decompose_to_targ
431
431
  @pytest.mark.parametrize(
432
432
  'gate',
433
433
  [
434
+ cirq.I,
435
+ cirq.GlobalPhaseGate(1),
436
+ cirq.GlobalPhaseGate(-1),
437
+ cirq.GlobalPhaseGate(1j),
434
438
  cirq.GlobalPhaseGate(1j**0.7),
439
+ cirq.Z,
435
440
  cirq.ZPowGate(exponent=1.2, global_shift=0.3),
441
+ cirq.CZ,
436
442
  cirq.CZPowGate(exponent=1.2, global_shift=0.3),
443
+ cirq.CCZ,
437
444
  cirq.CCZPowGate(exponent=1.2, global_shift=0.3),
445
+ cirq.X,
446
+ cirq.XPowGate(exponent=1.2, global_shift=0.3),
447
+ cirq.CX,
448
+ cirq.CXPowGate(exponent=1.2, global_shift=0.3),
449
+ cirq.CCX,
450
+ cirq.CCXPowGate(exponent=1.2, global_shift=0.3),
438
451
  ],
439
452
  )
440
453
  @pytest.mark.parametrize(
@@ -476,10 +489,9 @@ def _test_controlled_gate_is_consistent(
476
489
  shape = cirq.qid_shape(cgate)
477
490
  qids = cirq.LineQid.for_qid_shape(shape)
478
491
  decomposed = cirq.decompose(cgate.on(*qids))
479
- if len(decomposed) < 1000: # CCCCCZ rounding error explodes
480
- first_op = cirq.IdentityGate(qid_shape=shape).on(*qids) # To ensure same qid order
481
- circuit = cirq.Circuit(first_op, *decomposed)
482
- np.testing.assert_allclose(cirq.unitary(cgate), cirq.unitary(circuit), atol=1e-1)
492
+ first_op = cirq.IdentityGate(qid_shape=shape).on(*qids) # To ensure same qid order
493
+ circuit = cirq.Circuit(first_op, *decomposed)
494
+ np.testing.assert_allclose(cirq.unitary(cgate), cirq.unitary(circuit), atol=1e-13)
483
495
 
484
496
 
485
497
  def test_pow_inverse():
cirq/ops/eigen_gate.py CHANGED
@@ -34,7 +34,6 @@ import numpy as np
34
34
  import sympy
35
35
 
36
36
  from cirq import protocols, value
37
- from cirq.linalg import tolerance
38
37
  from cirq.ops import raw_types
39
38
 
40
39
  if TYPE_CHECKING:
@@ -122,7 +121,6 @@ class EigenGate(raw_types.Gate):
122
121
  exponent = exponent.real
123
122
  self._exponent = exponent
124
123
  self._global_shift = global_shift
125
- self._canonical_exponent_cached = None
126
124
 
127
125
  @property
128
126
  def exponent(self) -> value.TParamVal:
@@ -305,30 +303,19 @@ class EigenGate(raw_types.Gate):
305
303
  return NotImplemented # pragma: no cover
306
304
  return self._with_exponent(exponent=new_exponent)
307
305
 
308
- @property
309
- def _canonical_exponent(self):
310
- if self._canonical_exponent_cached is None:
311
- period = self._period()
312
- if not period:
313
- self._canonical_exponent_cached = self._exponent
314
- elif protocols.is_parameterized(self._exponent):
315
- self._canonical_exponent_cached = self._exponent
316
- if isinstance(self._exponent, sympy.Number):
317
- self._canonical_exponent_cached = float(self._exponent)
318
- else:
319
- self._canonical_exponent_cached = self._exponent % period
320
- return self._canonical_exponent_cached
321
-
322
306
  def _value_equality_values_(self):
323
- return self._canonical_exponent, self._global_shift
307
+ """The phases by which we multiply the eigenspaces.
324
308
 
325
- def _value_equality_approximate_values_(self):
326
- period = self._period()
327
- if not period or protocols.is_parameterized(self._exponent):
328
- exponent = self._exponent
329
- else:
330
- exponent = value.PeriodicValue(self._exponent, period)
331
- return exponent, self._global_shift
309
+ The default implementation assumes that the eigenspaces are constant
310
+ for the class, and the eigenphases are the only distinguishing
311
+ characteristics. For gates whose eigenspaces can change, such as
312
+ `PhasedISwapPowGate`, this must be overridden to provide the additional
313
+ fields that affect the eigenspaces.
314
+ """
315
+ symbolic = lambda x: isinstance(x, sympy.Expr) and x.free_symbols
316
+ f = lambda x: x if symbolic(x) else float(x)
317
+ shifts = (f(self._exponent) * f(self._global_shift + e) for e in self._eigen_shifts())
318
+ return tuple(s if symbolic(s) else value.PeriodicValue(f(s), 2) for s in shifts)
332
319
 
333
320
  def _trace_distance_bound_(self) -> Optional[float]:
334
321
  if protocols.is_parameterized(self._exponent):
@@ -378,20 +365,9 @@ class EigenGate(raw_types.Gate):
378
365
  return False
379
366
  self_without_phase = self._with_exponent(self.exponent)
380
367
  self_without_phase._global_shift = 0
381
- self_without_exp_or_phase = self_without_phase._with_exponent(0)
382
- self_without_exp_or_phase._global_shift = 0
383
368
  other_without_phase = other._with_exponent(other.exponent)
384
369
  other_without_phase._global_shift = 0
385
- other_without_exp_or_phase = other_without_phase._with_exponent(0)
386
- other_without_exp_or_phase._global_shift = 0
387
- if not protocols.approx_eq(
388
- self_without_exp_or_phase, other_without_exp_or_phase, atol=atol
389
- ):
390
- return False
391
-
392
- period = self_without_phase._period()
393
- exponents_diff = exponents[0] - exponents[1]
394
- return tolerance.near_zero_mod(exponents_diff, period, atol=atol)
370
+ return protocols.approx_eq(self_without_phase, other_without_phase, atol=atol)
395
371
 
396
372
  def _json_dict_(self) -> Dict[str, Any]:
397
373
  return protocols.obj_to_dict_helper(self, ['exponent', 'global_shift'])
@@ -12,7 +12,6 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
- import re
16
15
  from typing import List, Tuple
17
16
 
18
17
  import numpy as np
@@ -50,7 +49,7 @@ class CExpZinGate(cirq.EigenGate, cirq.testing.TwoQubitGate):
50
49
  ]
51
50
 
52
51
 
53
- class ZGateDef(cirq.EigenGate, cirq.testing.TwoQubitGate):
52
+ class ZGateDef(cirq.EigenGate, cirq.testing.SingleQubitGate):
54
53
  @property
55
54
  def exponent(self):
56
55
  return self._exponent
@@ -97,7 +96,6 @@ def test_eq():
97
96
  eq.make_equality_group(lambda: CExpZinGate(quarter_turns=0.1))
98
97
  eq.add_equality_group(CExpZinGate(0), CExpZinGate(4), CExpZinGate(-4))
99
98
 
100
- # Equates by canonicalized period.
101
99
  eq.add_equality_group(CExpZinGate(1.5), CExpZinGate(41.5))
102
100
  eq.add_equality_group(CExpZinGate(3.5), CExpZinGate(-0.5))
103
101
 
@@ -109,6 +107,64 @@ def test_eq():
109
107
  eq.add_equality_group(ZGateDef(exponent=0.5, global_shift=0.5))
110
108
  eq.add_equality_group(ZGateDef(exponent=1.0, global_shift=0.5))
111
109
 
110
+ # All variants of (0,0) == (0*a,0*a) == (0, 2) == (2, 2)
111
+ a, b = sympy.symbols('a, b')
112
+ eq.add_equality_group(
113
+ WeightedZPowGate(0),
114
+ WeightedZPowGate(0) ** 1.1,
115
+ WeightedZPowGate(0) ** a,
116
+ (WeightedZPowGate(0) ** a) ** 1.2,
117
+ WeightedZPowGate(0) ** (a + 1.3),
118
+ WeightedZPowGate(0) ** b,
119
+ WeightedZPowGate(1) ** 2,
120
+ WeightedZPowGate(0, global_shift=1) ** 2,
121
+ WeightedZPowGate(1, global_shift=1) ** 2,
122
+ WeightedZPowGate(2),
123
+ WeightedZPowGate(0, global_shift=2),
124
+ WeightedZPowGate(2, global_shift=2),
125
+ )
126
+ # WeightedZPowGate(2) is identity, but non-integer exponent would make it different, similar to
127
+ # how we treat (X**2)**0.5==X. So these are in their own equality group. (0, 2*a)
128
+ eq.add_equality_group(
129
+ WeightedZPowGate(2) ** a,
130
+ (WeightedZPowGate(1) ** 2) ** a,
131
+ (WeightedZPowGate(1) ** a) ** 2,
132
+ WeightedZPowGate(1) ** (a * 2),
133
+ WeightedZPowGate(1) ** (a + a),
134
+ )
135
+ # Similarly, these are identity without the exponent, but global_shift affects both phases
136
+ # instead of just the one, so will have a different effect from the above depending on the
137
+ # exponent. (2*a, 0)
138
+ eq.add_equality_group(
139
+ WeightedZPowGate(0, global_shift=2) ** a,
140
+ (WeightedZPowGate(0, global_shift=1) ** 2) ** a,
141
+ (WeightedZPowGate(0, global_shift=1) ** a) ** 2,
142
+ WeightedZPowGate(0, global_shift=1) ** (a * 2),
143
+ WeightedZPowGate(0, global_shift=1) ** (a + a),
144
+ )
145
+ # Symbolic exponents that cancel (0, 1) == (0, a/a)
146
+ eq.add_equality_group(
147
+ WeightedZPowGate(1),
148
+ WeightedZPowGate(a) ** (1 / a),
149
+ WeightedZPowGate(b) ** (1 / b),
150
+ WeightedZPowGate(1 / a) ** a,
151
+ WeightedZPowGate(1 / b) ** b,
152
+ )
153
+ # Symbol in one phase and constant off by period in another (0, a) == (2, a)
154
+ eq.add_equality_group(
155
+ WeightedZPowGate(a),
156
+ WeightedZPowGate(a - 2, global_shift=2),
157
+ WeightedZPowGate(1 - 2 / a, global_shift=2 / a) ** a,
158
+ )
159
+ # Different symbol, different equality group (0, b)
160
+ eq.add_equality_group(WeightedZPowGate(b))
161
+ # Various number types
162
+ eq.add_equality_group(
163
+ WeightedZPowGate(np.int64(3), global_shift=sympy.Number(5)) ** 7.0,
164
+ WeightedZPowGate(sympy.Number(3), global_shift=5.0) ** np.int64(7),
165
+ WeightedZPowGate(3.0, global_shift=np.int64(5)) ** sympy.Number(7),
166
+ )
167
+
112
168
 
113
169
  def test_approx_eq():
114
170
  assert cirq.approx_eq(CExpZinGate(1.5), CExpZinGate(1.5), atol=0.1)
@@ -118,8 +174,7 @@ def test_approx_eq():
118
174
  assert cirq.approx_eq(ZGateDef(exponent=1.5), ZGateDef(exponent=1.5), atol=0.1)
119
175
  assert not cirq.approx_eq(CExpZinGate(1.5), ZGateDef(exponent=1.5), atol=0.1)
120
176
  with pytest.raises(
121
- TypeError,
122
- match=re.escape("unsupported operand type(s) for -: 'Symbol' and 'PeriodicValue'"),
177
+ TypeError, match="unsupported operand type\\(s\\) for -: '.*' and 'PeriodicValue'"
123
178
  ):
124
179
  cirq.approx_eq(ZGateDef(exponent=1.5), ZGateDef(exponent=sympy.Symbol('a')), atol=0.1)
125
180
  assert cirq.approx_eq(CExpZinGate(sympy.Symbol('a')), CExpZinGate(sympy.Symbol('a')), atol=0.1)
@@ -333,11 +388,6 @@ class WeightedZPowGate(cirq.EigenGate, cirq.testing.SingleQubitGate):
333
388
  self.weight = weight
334
389
  super().__init__(**kwargs)
335
390
 
336
- def _value_equality_values_(self):
337
- return self.weight, self._canonical_exponent, self._global_shift
338
-
339
- _value_equality_approximate_values_ = _value_equality_values_
340
-
341
391
  def _eigen_components(self) -> List[Tuple[float, np.ndarray]]:
342
392
  return [(0, np.diag([1, 0])), (self.weight, np.diag([0, 1]))]
343
393
 
cirq/ops/matrix_gates.py CHANGED
@@ -14,13 +14,13 @@
14
14
 
15
15
  """Quantum gates defined by a matrix."""
16
16
 
17
- from typing import Any, Dict, Iterable, Optional, Tuple, TYPE_CHECKING
17
+ from typing import Any, Dict, Iterable, List, Optional, Tuple, TYPE_CHECKING
18
18
 
19
19
  import numpy as np
20
20
 
21
21
  from cirq import _import, linalg, protocols
22
22
  from cirq._compat import proper_repr
23
- from cirq.ops import phased_x_z_gate, raw_types
23
+ from cirq.ops import global_phase_op, identity, phased_x_z_gate, raw_types
24
24
 
25
25
  if TYPE_CHECKING:
26
26
  import cirq
@@ -148,18 +148,34 @@ class MatrixGate(raw_types.Gate):
148
148
  return MatrixGate(matrix=result.reshape(self._matrix.shape), qid_shape=self._qid_shape)
149
149
 
150
150
  def _decompose_(self, qubits: Tuple['cirq.Qid', ...]) -> 'cirq.OP_TREE':
151
+ from cirq.circuits import Circuit
152
+
153
+ decomposed: List['cirq.Operation'] = NotImplemented
151
154
  if self._qid_shape == (2,):
152
- return [
155
+ decomposed = [
153
156
  g.on(qubits[0])
154
157
  for g in single_qubit_decompositions.single_qubit_matrix_to_gates(self._matrix)
155
158
  ]
156
159
  if self._qid_shape == (2,) * 2:
157
- return two_qubit_to_cz.two_qubit_matrix_to_cz_operations(
160
+ decomposed = two_qubit_to_cz.two_qubit_matrix_to_cz_operations(
158
161
  *qubits, self._matrix, allow_partial_czs=True
159
162
  )
160
163
  if self._qid_shape == (2,) * 3:
161
- return three_qubit_decomposition.three_qubit_matrix_to_operations(*qubits, self._matrix)
162
- return NotImplemented
164
+ decomposed = three_qubit_decomposition.three_qubit_matrix_to_operations(
165
+ *qubits, self._matrix
166
+ )
167
+ if decomposed is NotImplemented:
168
+ return NotImplemented
169
+ # The above algorithms ignore phase, but phase is important to maintain if the gate is
170
+ # controlled. Here, we add it back in with a global phase op.
171
+ ident = identity.IdentityGate(qid_shape=self._qid_shape).on(*qubits) # Preserve qid order
172
+ u = protocols.unitary(Circuit(ident, *decomposed)).reshape(self._matrix.shape)
173
+ phase_delta = linalg.phase_delta(u, self._matrix)
174
+ # Phase delta is on the complex unit circle, so if real(phase_delta) >= 1, that means
175
+ # no phase delta. (>1 is rounding error).
176
+ if phase_delta.real < 1:
177
+ decomposed.append(global_phase_op.global_phase_operation(phase_delta))
178
+ return decomposed
163
179
 
164
180
  def _has_unitary_(self) -> bool:
165
181
  return True
@@ -39,6 +39,7 @@ def test_xx_eq():
39
39
  cirq.XXPowGate(),
40
40
  cirq.XXPowGate(exponent=1, global_shift=0),
41
41
  cirq.XXPowGate(exponent=3, global_shift=0),
42
+ cirq.XXPowGate(global_shift=100000),
42
43
  )
43
44
  eq.add_equality_group(cirq.XX**0.5, cirq.XX**2.5, cirq.XX**4.5)
44
45
  eq.add_equality_group(cirq.XX**0.25, cirq.XX**2.25, cirq.XX**-1.75)
cirq/ops/pauli_gates.py CHANGED
@@ -103,11 +103,6 @@ class Pauli(raw_types.Gate, metaclass=abc.ABCMeta):
103
103
 
104
104
  return pauli_string.SingleQubitPauliStringGateOperation(self, qubits[0])
105
105
 
106
- @property
107
- def _canonical_exponent(self):
108
- """Overrides EigenGate._canonical_exponent in subclasses."""
109
- return 1
110
-
111
106
 
112
107
  class _PauliX(Pauli, common_gates.XPowGate):
113
108
  def __init__(self):
@@ -85,7 +85,13 @@ class PauliInteractionGate(gate_features.InterchangeableQubitsGate, eigen_gate.E
85
85
  return 2
86
86
 
87
87
  def _value_equality_values_(self):
88
- return (self.pauli0, self.invert0, self.pauli1, self.invert1, self._canonical_exponent)
88
+ return (
89
+ self.pauli0,
90
+ self.invert0,
91
+ self.pauli1,
92
+ self.invert1,
93
+ value.PeriodicValue(self.exponent, 2),
94
+ )
89
95
 
90
96
  def qubit_index_to_equivalence_group_key(self, index: int) -> int:
91
97
  if self.pauli0 == self.pauli1 and self.invert0 == self.invert1:
@@ -24,7 +24,7 @@ from cirq import ops, transformers as opt
24
24
 
25
25
  def three_qubit_matrix_to_operations(
26
26
  q0: ops.Qid, q1: ops.Qid, q2: ops.Qid, u: np.ndarray, atol: float = 1e-8
27
- ) -> Sequence[ops.Operation]:
27
+ ) -> List[ops.Operation]:
28
28
  """Returns operations for a 3 qubit unitary.
29
29
 
30
30
  The algorithm is described in Shende et al.:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20250404223605
3
+ Version: 1.5.0.dev20250405043305
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
@@ -4,8 +4,8 @@ cirq/_compat_test.py,sha256=0m3sYIyxRNv9jvAo6rzJ-cnbpny3KGnAByrbU7bApgQ,34720
4
4
  cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
5
5
  cirq/_import.py,sha256=cfocxtT1BJ4HkfZ-VO8YyIhPP-xfqHDkLrzz6eeO5U0,8421
6
6
  cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
7
- cirq/_version.py,sha256=Tja5jq4ZrUbxGzBYypqgXJT1__o9xiTAx9c3vNmlPbY,1206
8
- cirq/_version_test.py,sha256=GGaXFIDTlMYYzMzMj-1y847R2wQeIHZBZdds2Y45nmE,147
7
+ cirq/_version.py,sha256=lcCzHo7o7aBVgMbzjtSwrvnpFHV1Hut93nbUgxA0ibU,1206
8
+ cirq/_version_test.py,sha256=6ZYv5DT6HSuJAbOiQc4EeFJuUzypuwLQTA2AHZusBCI,147
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=YVamU72nCUT5dG0bhAvRKVX5lXcZMNTwP3H36v-cYag,13615
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -248,7 +248,7 @@ cirq/interop/quirk/cells/testing_test.py,sha256=Qb__MOXjUrna7Wy6mlRWFyyy78KfzqlK
248
248
  cirq/interop/quirk/cells/unsupported_cells.py,sha256=xTE4aKpuVocey_lvWwb8Q1fla6oMqI1S4rc7a2UtDgs,2841
249
249
  cirq/interop/quirk/cells/unsupported_cells_test.py,sha256=5bl-maazy7Dr8u6kwK1AhGT4vtHqzIMRKxoMKYC-JWs,2178
250
250
  cirq/ion/__init__.py,sha256=F6tf4JZOGpDdxX0FxT42qgq8rF96ZTFHMJ0OV09Yj1c,787
251
- cirq/linalg/__init__.py,sha256=9WLnBqLQ02FzCIUcchHBMYpOGVcENAjzv7GyDNgh89I,4013
251
+ cirq/linalg/__init__.py,sha256=0dSlIBy-TVzf7b_-rLLlrS8ZFkgCfYg0pJjWs72xYOk,4045
252
252
  cirq/linalg/combinators.py,sha256=0tts29gbwQg9lpZvCSX8QKMIMf38NGGdBJqI911m7jA,5336
253
253
  cirq/linalg/combinators_test.py,sha256=eRy1FrGujE8UC3pP1X5MfWmKlpjimHTxdiixr-G4nJM,4829
254
254
  cirq/linalg/decompositions.py,sha256=9dOJSJuYG8_dk3zdBO5rXDONKkw7SKZd5ZpWK4FnypQ,38652
@@ -261,8 +261,8 @@ cirq/linalg/predicates.py,sha256=vLTRaAYqVf0mk6Qgm53ROhLDtXxxoEhHbYxQN74aGRk,120
261
261
  cirq/linalg/predicates_test.py,sha256=syNiyS-clEGeZnbKT7zyR8_ClDnXFYtDnLKozLbitzw,21504
262
262
  cirq/linalg/tolerance.py,sha256=a68RNOmCw0ybFwhXOq6DERK5gHAOlPJIRdPuMzV6xuU,1870
263
263
  cirq/linalg/tolerance_test.py,sha256=wnmuXIGEn_mugGoNm3AigSgjV2DMFdj8xpgRTMBbO7A,2355
264
- cirq/linalg/transformations.py,sha256=cUZWPZJq6DISQ4rS02KSObmNwqLHYxIkNCfYijgJLoA,31986
265
- cirq/linalg/transformations_test.py,sha256=GsqD8_X0N88ECKr44t0O9wAJ6-uJJi0wExivn0Okf7M,25333
264
+ cirq/linalg/transformations.py,sha256=zo9Gwo4VX2uQfN_7iOzQrxI-27uDj7s8eTUe2eJQetU,32519
265
+ cirq/linalg/transformations_test.py,sha256=4GnfQhB1lERteVxvTHXMXxEt4vwQLZBXNJOvnFY3AKY,25636
266
266
  cirq/neutral_atoms/__init__.py,sha256=VoQBkmZ5m4TPxjxShRixjqJbnc-IAnAWkGOPu8MBS5o,813
267
267
  cirq/neutral_atoms/convert_to_neutral_atom_gates.py,sha256=SsXFh1-NoBGqp4yX8-jIbIw-AK40baA-qh-iTL1wS6Q,1070
268
268
  cirq/neutral_atoms/convert_to_neutral_atom_gates_test.py,sha256=svleNo8P_cQLCMfcGLkU896cpLjZKPynDKnJGM2pyJ0,1861
@@ -280,20 +280,20 @@ cirq/ops/common_channels.py,sha256=LfIjy4WBRF_K81kc12Y4nLjdVZnJUhIKHL7sxiNNINU,3
280
280
  cirq/ops/common_channels_test.py,sha256=nQsSSxu7vtedb3ZUuw4hNKIX7MYI4x8lxvLyWMZNt10,30079
281
281
  cirq/ops/common_gate_families.py,sha256=2E31Qr_Yv1zI-r_MNWmr1xJYrEHHU45274iDrt_oKPE,8611
282
282
  cirq/ops/common_gate_families_test.py,sha256=bEF6Q6GtEOTc9kHM5WC1UIULPGnMPXdtm8gzLT_aNBI,5276
283
- cirq/ops/common_gates.py,sha256=nTW9PAOdkbDei01ZUx6N-D2V1zslRJnk8WS_-NJSdlg,58330
284
- cirq/ops/common_gates_test.py,sha256=6y6uPS29Lnby3YesV4YG8fmI1FWqj7BfPQEGbvJl928,46882
283
+ cirq/ops/common_gates.py,sha256=nZ5gOd4JPnq7k6jrnNILacMnG-43OzdQQj5W1Vw5JKI,57846
284
+ cirq/ops/common_gates_test.py,sha256=bASPqAkuN92Ij3CCAVwOftL0heIu3J5VPcCtmm6nVU0,46873
285
285
  cirq/ops/control_values.py,sha256=Loi_voLNOzPJpjD6AnQz8JrqJLOAUe0jvV3XB_0tTGE,13430
286
286
  cirq/ops/control_values_test.py,sha256=K8tbKM6b6PqMEL_lHLFzdrnWF1SkLN0Scft6YMT7FlE,12907
287
- cirq/ops/controlled_gate.py,sha256=Is4s8-yRZye3gkhg-dlte5zfdAiXYtioC0oP-BXQ37g,15531
288
- cirq/ops/controlled_gate_test.py,sha256=6Z_HaIbXXKOJOhwb2l_Dmtfx9tcggl_vYf8pkB_UDms,25205
287
+ cirq/ops/controlled_gate.py,sha256=uzQL7scPsKmnu3Kdiw-zF7b4FxdyqvaD6oPkczs1skQ,15234
288
+ cirq/ops/controlled_gate_test.py,sha256=8PprvTdGMfBQOOQ-BpW_decRQU39P2gM_xJfX-fawMo,25512
289
289
  cirq/ops/controlled_operation.py,sha256=kfZUj5XISlHJGvm2mzn7-UzNmIFimLMNvn9QhD68Lro,14077
290
290
  cirq/ops/controlled_operation_test.py,sha256=kHdHGR6Q6ROgUJqG4DSKOvyrLJhi-u4uMh-rM3QRJ8o,16525
291
291
  cirq/ops/dense_pauli_string.py,sha256=nQs4lfm9zSGPGE9p9KAJbEhkldpg9krqTwvIkLePs90,24477
292
292
  cirq/ops/dense_pauli_string_test.py,sha256=duvgzhgTV9wuem4kDSwtL62SEUCThkz1tdP984-C4_s,21504
293
293
  cirq/ops/diagonal_gate.py,sha256=NpCGuZpdqMGoM6ya8Q8Jp7UTut2WglMB7DK5oqBRXiE,9021
294
294
  cirq/ops/diagonal_gate_test.py,sha256=wsPZWhImVGNrEg1mYnXsO4nJ6VziDBfvEilAFtJJ8b4,6224
295
- cirq/ops/eigen_gate.py,sha256=ci_5rhFZxiSIKa7e1-jTPrVX3AsIFsEF7lkGbww57eE,18343
296
- cirq/ops/eigen_gate_test.py,sha256=vWYAMKN9EwDRxXelkOXu0-c3TGz2l6A2atf-zqr7hfA,13928
295
+ cirq/ops/eigen_gate.py,sha256=GRtLML2LbTBvVMNlar5SIzdDVK6UHL3lRwAPR6JOPOQ,17494
296
+ cirq/ops/eigen_gate_test.py,sha256=D9ETnoJ4NRcz9EvzQOFra84bonph8optp7zhW57rgWA,16139
297
297
  cirq/ops/fourier_transform.py,sha256=_YWqBq7zqRv7rH5oQPPg7zdUSiTp2px8kaaWZZmakZA,7513
298
298
  cirq/ops/fourier_transform_test.py,sha256=mtWhiC_Tg60uNh7mhhMb02cckGfNC_Tjte-Q4gRcF8c,6226
299
299
  cirq/ops/fsim_gate.py,sha256=Avzlcb_O201K0_tBmNR5m9fWkpBM7Nby0MfJjNJ9g_8,20136
@@ -314,7 +314,7 @@ cirq/ops/kraus_channel.py,sha256=qX828mvPSFgEaG0I3Jhj04y5rD7dUjeEl2HYDn7_7j4,508
314
314
  cirq/ops/kraus_channel_test.py,sha256=-E6ExIO3P0y2T74Gx-RMu0kLpy1RWP9wH6UGDI21oFU,4820
315
315
  cirq/ops/linear_combinations.py,sha256=PE1o_mvpdnlg3o95iSn5ID18kuxwS2q3DGDuFnlNC90,39916
316
316
  cirq/ops/linear_combinations_test.py,sha256=ip-wN8T8nUQviD3ql42eet7k_MQ6DVUfIK8aX-_ygOs,67217
317
- cirq/ops/matrix_gates.py,sha256=q-lyxDVg5K-eokmZWPN1woUmJkR90IpbNhnFqQgjw4Q,9297
317
+ cirq/ops/matrix_gates.py,sha256=PoaJuONeh7wFQ0iJUtMsN-OdvYW9wm_q8kFBLWu6I1k,10221
318
318
  cirq/ops/matrix_gates_test.py,sha256=m5rMwq_sqVvsmkc5opVr3Ikd1ERuULmSRNAvGZUg7ds,14224
319
319
  cirq/ops/measure_util.py,sha256=ZaH1Lze4Yk3nYrojn7SILUeIN96p_khIoa25ixXLu6A,7390
320
320
  cirq/ops/measure_util_test.py,sha256=Yzlced4nb4DHO-0cM_a-QZGO_3R8oqExkpIALN_pG4A,5307
@@ -329,10 +329,10 @@ cirq/ops/op_tree_test.py,sha256=FzDaDjooimUEYvCvXrTCXbR2Je8QjRTZ0VXoeI7AGyo,5700
329
329
  cirq/ops/parallel_gate.py,sha256=lkwaatEWd0roRbRKq_fkBz7nmZoMB4hdwFT6LUNxmJ4,6318
330
330
  cirq/ops/parallel_gate_test.py,sha256=lWCLnlEhs_LDNgewp7e3uN-23Q513i4G0JMva96_GiE,6299
331
331
  cirq/ops/parity_gates.py,sha256=WjuWb69Deym_g22ZJIurrMGY0AWdLQjxNkOFnnrbzAg,14383
332
- cirq/ops/parity_gates_test.py,sha256=7C0BmJl1HuoyVzfA8-lVCTiE1qNYQhMtyQlVx2uvFKA,11244
333
- cirq/ops/pauli_gates.py,sha256=WcjbuCjO3IjeEihvN5hb3-dXl8lnuG76EKKzihpvCAI,6967
332
+ cirq/ops/parity_gates_test.py,sha256=43k4Q6YIm2wOVxaAgp02ki0zpAQ271_lcG2GbWR4TJc,11289
333
+ cirq/ops/pauli_gates.py,sha256=NTt6Jd1WrlkqyvEDNKTLvzSR5pE4Imr-SDTZUs3gPgA,6831
334
334
  cirq/ops/pauli_gates_test.py,sha256=3AX2hzr-xeXrZUeSr-yBFYhbLeHK1qEh7_Bq9vGUAgo,7753
335
- cirq/ops/pauli_interaction_gate.py,sha256=MmFg4U_y0uomIwb03FaDPGiGzBCVRk7Kuo_eNXpLdXQ,5519
335
+ cirq/ops/pauli_interaction_gate.py,sha256=2e0VaCO0IE0rdwPb5F50S3rujqOuSWz54r2lNWUDrBA,5603
336
336
  cirq/ops/pauli_interaction_gate_test.py,sha256=adnIIgCvFzO-inNaN77HER-WJ0hg6L63_HfiT60oV3M,4543
337
337
  cirq/ops/pauli_measurement_gate.py,sha256=ODHQJgy7oEuDb7qOJ2ja_i0w4jvbV202FaO4O_deo6Y,7239
338
338
  cirq/ops/pauli_measurement_gate_test.py,sha256=acKmYvwSQniIX2FtOCVrIPRPmyUBeV4uNUFmyShJixE,6778
@@ -1097,7 +1097,7 @@ cirq/transformers/analytical_decompositions/single_qubit_decompositions.py,sha25
1097
1097
  cirq/transformers/analytical_decompositions/single_qubit_decompositions_test.py,sha256=4GfU6wctBoG-OVFqFOE08xymd5dXzY-doE8ZNpsKohI,12308
1098
1098
  cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry.py,sha256=Qmxv4YJgiBSbZUoonwSSBGGmzuPsUQLQbNTk2z59xRg,2439
1099
1099
  cirq/transformers/analytical_decompositions/single_to_two_qubit_isometry_test.py,sha256=qBoSS8OoM2HdOIM_46pSdbWFsQBu0aeQxUqiJ9znlnk,2517
1100
- cirq/transformers/analytical_decompositions/three_qubit_decomposition.py,sha256=3nCZItd7ZZ2IU0ysNuiM0OYn6RQGBCe9kF-H7kWlEBU,9746
1100
+ cirq/transformers/analytical_decompositions/three_qubit_decomposition.py,sha256=yrVbl6TKffGltCuDTxSs2vMoe5kMuv7R0yJKtOZjvm4,9742
1101
1101
  cirq/transformers/analytical_decompositions/three_qubit_decomposition_test.py,sha256=p9H-XuoQ3jdR5NTcAcbW6Pak69qGfzvBN4N1SDw5eg8,7847
1102
1102
  cirq/transformers/analytical_decompositions/two_qubit_state_preparation.py,sha256=OOjIy4Nw_28CdcmK5OE8uQEzy0wO5ITEF_tSZKaFSMM,6178
1103
1103
  cirq/transformers/analytical_decompositions/two_qubit_state_preparation_test.py,sha256=486hVPQp620r8SPKlhyaFIK8TC5jDngX8WqHY1Hb0Hk,4458
@@ -1209,8 +1209,8 @@ cirq/work/sampler.py,sha256=sW0RhIelGABAKbqTM58shwyyCPgf86JIv9IGdJe__js,19186
1209
1209
  cirq/work/sampler_test.py,sha256=mdk1J-WrvbPUYhY41VhWf9_te4DnXr_XMPcugWwc4-I,13281
1210
1210
  cirq/work/zeros_sampler.py,sha256=8_Ne6dBkDANtTZuql7Eb0Qg_E_P3-_gu-ybFzxTbKAQ,2356
1211
1211
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1212
- cirq_core-1.5.0.dev20250404223605.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1213
- cirq_core-1.5.0.dev20250404223605.dist-info/METADATA,sha256=A7r07ajCSfoWBJNYSNjlbgV9pixm0MeoES-quwKkb6s,4584
1214
- cirq_core-1.5.0.dev20250404223605.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1215
- cirq_core-1.5.0.dev20250404223605.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1216
- cirq_core-1.5.0.dev20250404223605.dist-info/RECORD,,
1212
+ cirq_core-1.5.0.dev20250405043305.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1213
+ cirq_core-1.5.0.dev20250405043305.dist-info/METADATA,sha256=mP0FqihGxdqzrn2lCHUtmxPFrW_4FeXXFBMSk45NBrI,4584
1214
+ cirq_core-1.5.0.dev20250405043305.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1215
+ cirq_core-1.5.0.dev20250405043305.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1216
+ cirq_core-1.5.0.dev20250405043305.dist-info/RECORD,,