cirq-core 1.6.0.dev20250520183459__py3-none-any.whl → 1.6.0.dev20250520205704__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, 11, 0): # pragma: no cover
28
28
  'of cirq (e.g. "python -m pip install cirq==1.5.0")'
29
29
  )
30
30
 
31
- __version__ = "1.6.0.dev20250520183459"
31
+ __version__ = "1.6.0.dev20250520205704"
cirq/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq
3
3
 
4
4
 
5
5
  def test_version() -> None:
6
- assert cirq.__version__ == "1.6.0.dev20250520183459"
6
+ assert cirq.__version__ == "1.6.0.dev20250520205704"
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  import cirq
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  import cirq
@@ -228,41 +228,54 @@ class QasmParser:
228
228
  }
229
229
 
230
230
  qelib_gates = {
231
- 'rx': QasmGateStatement(
232
- qasm_gate='rx', cirq_gate=(lambda params: ops.rx(params[0])), num_params=1, num_args=1
233
- ),
234
- 'sx': QasmGateStatement(
235
- qasm_gate='sx', num_params=0, num_args=1, cirq_gate=ops.XPowGate(exponent=0.5)
231
+ 'ccx': QasmGateStatement(qasm_gate='ccx', num_params=0, num_args=3, cirq_gate=ops.CCX),
232
+ 'ch': QasmGateStatement(
233
+ qasm_gate='ch', cirq_gate=ops.ControlledGate(ops.H), num_params=0, num_args=2
236
234
  ),
237
- 'sxdg': QasmGateStatement(
238
- qasm_gate='sxdg', num_params=0, num_args=1, cirq_gate=ops.XPowGate(exponent=-0.5)
235
+ 'crx': QasmGateStatement(
236
+ qasm_gate='crx',
237
+ num_params=1,
238
+ num_args=2,
239
+ cirq_gate=(lambda params: ops.ControlledGate(ops.rx(params[0]))),
239
240
  ),
240
- 'ry': QasmGateStatement(
241
- qasm_gate='ry', cirq_gate=(lambda params: ops.ry(params[0])), num_params=1, num_args=1
241
+ 'cry': QasmGateStatement(
242
+ qasm_gate='cry',
243
+ num_params=1,
244
+ num_args=2,
245
+ cirq_gate=(lambda params: ops.ControlledGate(ops.ry(params[0]))),
242
246
  ),
243
- 'rz': QasmGateStatement(
244
- qasm_gate='rz', cirq_gate=(lambda params: ops.rz(params[0])), num_params=1, num_args=1
247
+ 'crz': QasmGateStatement(
248
+ qasm_gate='crz',
249
+ num_params=1,
250
+ num_args=2,
251
+ cirq_gate=(lambda params: ops.ControlledGate(ops.rz(params[0]))),
245
252
  ),
246
- 'id': QasmGateStatement(
247
- qasm_gate='id', cirq_gate=ops.IdentityGate(1), num_params=0, num_args=1
253
+ 'cswap': QasmGateStatement(
254
+ qasm_gate='cswap', num_params=0, num_args=3, cirq_gate=ops.CSWAP
248
255
  ),
249
- 'u1': QasmGateStatement(
250
- qasm_gate='u1',
251
- cirq_gate=(lambda params: QasmUGate(0, 0, params[0] / np.pi)),
256
+ 'cu1': QasmGateStatement(
257
+ qasm_gate='cu1',
252
258
  num_params=1,
253
- num_args=1,
254
- ),
255
- 'u2': QasmGateStatement(
256
- qasm_gate='u2',
257
- cirq_gate=(lambda params: QasmUGate(0.5, params[0] / np.pi, params[1] / np.pi)),
258
- num_params=2,
259
- num_args=1,
259
+ num_args=2,
260
+ cirq_gate=(lambda params: ops.ControlledGate(QasmUGate(0, 0, params[0] / np.pi))),
260
261
  ),
261
- 'u3': QasmGateStatement(
262
- qasm_gate='u3',
262
+ 'cu3': QasmGateStatement(
263
+ qasm_gate='cu3',
263
264
  num_params=3,
264
- num_args=1,
265
- cirq_gate=(lambda params: QasmUGate(*[p / np.pi for p in params])),
265
+ num_args=2,
266
+ cirq_gate=(lambda params: ops.ControlledGate(QasmUGate(*[p / np.pi for p in params]))),
267
+ ),
268
+ 'cx': QasmGateStatement(qasm_gate='cx', cirq_gate=CX, num_params=0, num_args=2),
269
+ 'cy': QasmGateStatement(
270
+ qasm_gate='cy', cirq_gate=ops.ControlledGate(ops.Y), num_params=0, num_args=2
271
+ ),
272
+ 'cz': QasmGateStatement(qasm_gate='cz', cirq_gate=ops.CZ, num_params=0, num_args=2),
273
+ 'h': QasmGateStatement(qasm_gate='h', num_params=0, num_args=1, cirq_gate=ops.H),
274
+ 'id': QasmGateStatement(
275
+ qasm_gate='id', cirq_gate=ops.IdentityGate(1), num_params=0, num_args=1
276
+ ),
277
+ 'iswap': QasmGateStatement(
278
+ qasm_gate='iswap', cirq_gate=ops.ISwapPowGate(), num_params=0, num_args=2
266
279
  ),
267
280
  'r': QasmGateStatement(
268
281
  qasm_gate='r',
@@ -274,45 +287,65 @@ class QasmParser:
274
287
  )
275
288
  ),
276
289
  ),
277
- 'x': QasmGateStatement(qasm_gate='x', num_params=0, num_args=1, cirq_gate=ops.X),
278
- 'y': QasmGateStatement(qasm_gate='y', num_params=0, num_args=1, cirq_gate=ops.Y),
279
- 'z': QasmGateStatement(qasm_gate='z', num_params=0, num_args=1, cirq_gate=ops.Z),
280
- 'h': QasmGateStatement(qasm_gate='h', num_params=0, num_args=1, cirq_gate=ops.H),
281
- 's': QasmGateStatement(qasm_gate='s', num_params=0, num_args=1, cirq_gate=ops.S),
282
- 't': QasmGateStatement(qasm_gate='t', num_params=0, num_args=1, cirq_gate=ops.T),
283
- 'cx': QasmGateStatement(qasm_gate='cx', cirq_gate=CX, num_params=0, num_args=2),
284
- 'cy': QasmGateStatement(
285
- qasm_gate='cy', cirq_gate=ops.ControlledGate(ops.Y), num_params=0, num_args=2
290
+ 'rx': QasmGateStatement(
291
+ qasm_gate='rx', cirq_gate=(lambda params: ops.rx(params[0])), num_params=1, num_args=1
286
292
  ),
287
- 'cz': QasmGateStatement(qasm_gate='cz', cirq_gate=ops.CZ, num_params=0, num_args=2),
288
- 'ch': QasmGateStatement(
289
- qasm_gate='ch', cirq_gate=ops.ControlledGate(ops.H), num_params=0, num_args=2
293
+ 'ry': QasmGateStatement(
294
+ qasm_gate='ry', cirq_gate=(lambda params: ops.ry(params[0])), num_params=1, num_args=1
290
295
  ),
291
- 'cu1': QasmGateStatement(
292
- qasm_gate='cu1',
296
+ 'ryy': QasmGateStatement(
297
+ qasm_gate='ryy',
293
298
  num_params=1,
294
299
  num_args=2,
295
- cirq_gate=(lambda params: ops.ControlledGate(QasmUGate(0, 0, params[0] / np.pi))),
300
+ cirq_gate=(lambda params: ops.YYPowGate(exponent=params[0] / np.pi)),
296
301
  ),
297
- 'cu3': QasmGateStatement(
298
- qasm_gate='cu3',
299
- num_params=3,
302
+ 'rz': QasmGateStatement(
303
+ qasm_gate='rz', cirq_gate=(lambda params: ops.rz(params[0])), num_params=1, num_args=1
304
+ ),
305
+ 'rxx': QasmGateStatement(
306
+ qasm_gate='rxx',
307
+ num_params=1,
300
308
  num_args=2,
301
- cirq_gate=(lambda params: ops.ControlledGate(QasmUGate(*[p / np.pi for p in params]))),
309
+ cirq_gate=(lambda params: ops.XXPowGate(exponent=params[0] / np.pi)),
302
310
  ),
303
- 'crz': QasmGateStatement(
304
- qasm_gate='crz',
311
+ 'rzz': QasmGateStatement(
312
+ qasm_gate='rzz',
305
313
  num_params=1,
306
314
  num_args=2,
307
- cirq_gate=(lambda params: ops.ControlledGate(ops.rz(params[0]))),
315
+ cirq_gate=(lambda params: ops.ZZPowGate(exponent=params[0] / np.pi)),
308
316
  ),
317
+ 's': QasmGateStatement(qasm_gate='s', num_params=0, num_args=1, cirq_gate=ops.S),
318
+ 'sdg': QasmGateStatement(qasm_gate='sdg', num_params=0, num_args=1, cirq_gate=ops.S**-1),
309
319
  'swap': QasmGateStatement(qasm_gate='swap', cirq_gate=ops.SWAP, num_params=0, num_args=2),
310
- 'cswap': QasmGateStatement(
311
- qasm_gate='cswap', num_params=0, num_args=3, cirq_gate=ops.CSWAP
320
+ 'sx': QasmGateStatement(
321
+ qasm_gate='sx', num_params=0, num_args=1, cirq_gate=ops.XPowGate(exponent=0.5)
312
322
  ),
313
- 'ccx': QasmGateStatement(qasm_gate='ccx', num_params=0, num_args=3, cirq_gate=ops.CCX),
314
- 'sdg': QasmGateStatement(qasm_gate='sdg', num_params=0, num_args=1, cirq_gate=ops.S**-1),
323
+ 'sxdg': QasmGateStatement(
324
+ qasm_gate='sxdg', num_params=0, num_args=1, cirq_gate=ops.XPowGate(exponent=-0.5)
325
+ ),
326
+ 't': QasmGateStatement(qasm_gate='t', num_params=0, num_args=1, cirq_gate=ops.T),
315
327
  'tdg': QasmGateStatement(qasm_gate='tdg', num_params=0, num_args=1, cirq_gate=ops.T**-1),
328
+ 'u1': QasmGateStatement(
329
+ qasm_gate='u1',
330
+ cirq_gate=(lambda params: QasmUGate(0, 0, params[0] / np.pi)),
331
+ num_params=1,
332
+ num_args=1,
333
+ ),
334
+ 'u2': QasmGateStatement(
335
+ qasm_gate='u2',
336
+ cirq_gate=(lambda params: QasmUGate(0.5, params[0] / np.pi, params[1] / np.pi)),
337
+ num_params=2,
338
+ num_args=1,
339
+ ),
340
+ 'u3': QasmGateStatement(
341
+ qasm_gate='u3',
342
+ num_params=3,
343
+ num_args=1,
344
+ cirq_gate=(lambda params: QasmUGate(*[p / np.pi for p in params])),
345
+ ),
346
+ 'x': QasmGateStatement(qasm_gate='x', num_params=0, num_args=1, cirq_gate=ops.X),
347
+ 'y': QasmGateStatement(qasm_gate='y', num_params=0, num_args=1, cirq_gate=ops.Y),
348
+ 'z': QasmGateStatement(qasm_gate='z', num_params=0, num_args=1, cirq_gate=ops.Z),
316
349
  }
317
350
 
318
351
  tokens = QasmLexer.tokens
@@ -1053,7 +1053,7 @@ def test_two_qubit_gates_not_enough_args(qasm_gate: str) -> None:
1053
1053
  include "qelib1.inc";
1054
1054
  qreg q[2];
1055
1055
  {qasm_gate} q[0];
1056
- """
1056
+ """
1057
1057
 
1058
1058
  parser = QasmParser()
1059
1059
 
@@ -1514,3 +1514,159 @@ def test_nested_custom_gate_has_keyword_in_name() -> None:
1514
1514
  parser = QasmParser()
1515
1515
  parsed_qasm = parser.parse(qasm)
1516
1516
  assert parsed_qasm.circuit == expected
1517
+
1518
+
1519
+ def test_rzz_gate():
1520
+ qasm = """
1521
+ OPENQASM 2.0;
1522
+ include "qelib1.inc";
1523
+ qreg q[2];
1524
+ rzz(pi/2) q[0],q[1];
1525
+ """
1526
+ parser = QasmParser()
1527
+
1528
+ q0, q1 = cirq.NamedQubit('q_0'), cirq.NamedQubit('q_1')
1529
+
1530
+ expected_circuit = Circuit()
1531
+ expected_circuit.append(cirq.ZZPowGate(exponent=0.5).on(q0, q1))
1532
+
1533
+ parsed_qasm = parser.parse(qasm)
1534
+
1535
+ assert parsed_qasm.supportedFormat
1536
+ assert parsed_qasm.qelib1Include
1537
+
1538
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
1539
+ assert parsed_qasm.qregs == {'q': 2}
1540
+
1541
+
1542
+ def test_rxx_gate():
1543
+ qasm = """
1544
+ OPENQASM 2.0;
1545
+ include "qelib1.inc";
1546
+ qreg q[2];
1547
+ rxx(pi/4) q[0],q[1];
1548
+ """
1549
+ parser = QasmParser()
1550
+
1551
+ q0, q1 = cirq.NamedQubit('q_0'), cirq.NamedQubit('q_1')
1552
+
1553
+ expected_circuit = Circuit()
1554
+ expected_circuit.append(cirq.XXPowGate(exponent=0.25).on(q0, q1))
1555
+
1556
+ parsed_qasm = parser.parse(qasm)
1557
+
1558
+ assert parsed_qasm.supportedFormat
1559
+ assert parsed_qasm.qelib1Include
1560
+
1561
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
1562
+ assert parsed_qasm.qregs == {'q': 2}
1563
+
1564
+
1565
+ def test_ryy_gate():
1566
+ qasm = """
1567
+ OPENQASM 2.0;
1568
+ include "qelib1.inc";
1569
+ qreg q[2];
1570
+ ryy(pi/3) q[0],q[1];
1571
+ """
1572
+ parser = QasmParser()
1573
+
1574
+ q0, q1 = cirq.NamedQubit('q_0'), cirq.NamedQubit('q_1')
1575
+
1576
+ expected_circuit = Circuit()
1577
+ expected_circuit.append(cirq.YYPowGate(exponent=1 / 3).on(q0, q1))
1578
+
1579
+ parsed_qasm = parser.parse(qasm)
1580
+
1581
+ assert parsed_qasm.supportedFormat
1582
+ assert parsed_qasm.qelib1Include
1583
+
1584
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
1585
+ assert parsed_qasm.qregs == {'q': 2}
1586
+
1587
+
1588
+ def test_crx_gate():
1589
+ qasm = """
1590
+ OPENQASM 2.0;
1591
+ include "qelib1.inc";
1592
+ qreg q[2];
1593
+ crx(pi/7) q[0],q[1];
1594
+ """
1595
+ parser = QasmParser()
1596
+
1597
+ q0, q1 = cirq.NamedQubit('q_0'), cirq.NamedQubit('q_1')
1598
+
1599
+ expected_circuit = Circuit()
1600
+ expected_circuit.append(cirq.ControlledGate(cirq.rx(np.pi / 7)).on(q0, q1))
1601
+
1602
+ parsed_qasm = parser.parse(qasm)
1603
+
1604
+ assert parsed_qasm.supportedFormat
1605
+ assert parsed_qasm.qelib1Include
1606
+
1607
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
1608
+ assert parsed_qasm.qregs == {'q': 2}
1609
+
1610
+
1611
+ def test_iswap_gate():
1612
+ qasm = """
1613
+ OPENQASM 2.0;
1614
+ include "qelib1.inc";
1615
+ qreg q[2];
1616
+ iswap q[0],q[1];
1617
+ """
1618
+ parser = QasmParser()
1619
+
1620
+ q0, q1 = cirq.NamedQubit('q_0'), cirq.NamedQubit('q_1')
1621
+
1622
+ expected_circuit = Circuit()
1623
+ expected_circuit.append(cirq.ISwapPowGate().on(q0, q1))
1624
+
1625
+ parsed_qasm = parser.parse(qasm)
1626
+
1627
+ assert parsed_qasm.supportedFormat
1628
+ assert parsed_qasm.qelib1Include
1629
+
1630
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
1631
+ assert parsed_qasm.qregs == {'q': 2}
1632
+
1633
+
1634
+ @pytest.mark.parametrize(
1635
+ "qasm_gate,cirq_gate,num_params,num_args",
1636
+ [
1637
+ (name, stmt.cirq_gate, stmt.num_params, stmt.num_args)
1638
+ for name, stmt in QasmParser.qelib_gates.items()
1639
+ ],
1640
+ )
1641
+ @pytest.mark.parametrize(
1642
+ "theta,theta_str", [(np.pi / 4, "pi/4"), (np.pi / 2, "pi/2"), (np.pi, "pi")]
1643
+ )
1644
+ def test_all_qelib_gates_unitary_equivalence(
1645
+ qasm_gate, cirq_gate, num_params, num_args, theta, theta_str
1646
+ ):
1647
+ thetas = [theta] * num_params
1648
+ params_str = f"({','.join(theta_str for _ in range(num_params))})" if num_params else ""
1649
+ qubit_names, qubits = [], []
1650
+ for i in range(num_args):
1651
+ qubit_names.append(f"q[{i}]")
1652
+ qubits.append(cirq.NamedQubit(f"q_{i}"))
1653
+ qasm = f"""
1654
+ OPENQASM 2.0;
1655
+ include "qelib1.inc";
1656
+ qreg q[{num_args}];
1657
+ {qasm_gate}{params_str} {','.join(qubit_names)};
1658
+ """
1659
+
1660
+ parser = QasmParser()
1661
+ parsed_qasm = parser.parse(qasm)
1662
+ if num_params:
1663
+ gate = cirq_gate(thetas)
1664
+ else:
1665
+ gate = cirq_gate
1666
+ expected = Circuit()
1667
+ expected.append(gate.on(*qubits))
1668
+ imported = list(parsed_qasm.circuit.all_operations())[0].gate
1669
+ U_native = cirq.unitary(gate)
1670
+ U_import = cirq.unitary(imported)
1671
+ assert np.allclose(U_import, U_native, atol=1e-8)
1672
+ assert parsed_qasm.qregs == {'q': num_args}
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  import errno
cirq/ops/qubit_order.py CHANGED
@@ -12,10 +12,9 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
-
16
15
  from __future__ import annotations
17
16
 
18
- from typing import Any, Callable, Iterable, Optional, TYPE_CHECKING, TypeVar
17
+ from typing import Any, Callable, Iterable, TYPE_CHECKING, TypeVar
19
18
 
20
19
  if TYPE_CHECKING:
21
20
  import cirq
@@ -41,7 +40,7 @@ class QubitOrder:
41
40
 
42
41
  @staticmethod
43
42
  def explicit(
44
- fixed_qubits: Iterable[cirq.Qid], fallback: Optional[QubitOrder] = None
43
+ fixed_qubits: Iterable[cirq.Qid], fallback: QubitOrder | None = None
45
44
  ) -> QubitOrder:
46
45
  """A basis that contains exactly the given qubits in the given order.
47
46
 
@@ -271,7 +271,7 @@ def apply_channel(
271
271
  )
272
272
 
273
273
 
274
- def _apply_unitary(val: Any, args: 'ApplyChannelArgs') -> np.ndarray | None:
274
+ def _apply_unitary(val: Any, args: ApplyChannelArgs) -> np.ndarray | None:
275
275
  """Attempt to use `apply_unitary` and return the result.
276
276
 
277
277
  If `val` does not support `apply_unitary` returns None.
@@ -294,7 +294,7 @@ def _apply_unitary(val: Any, args: 'ApplyChannelArgs') -> np.ndarray | None:
294
294
  return right_result
295
295
 
296
296
 
297
- def _apply_kraus(kraus: tuple[np.ndarray] | Sequence[Any], args: 'ApplyChannelArgs') -> np.ndarray:
297
+ def _apply_kraus(kraus: tuple[np.ndarray] | Sequence[Any], args: ApplyChannelArgs) -> np.ndarray:
298
298
  """Directly apply the kraus operators to the target tensor."""
299
299
  # Initialize output.
300
300
  args.out_buffer[:] = 0
@@ -309,7 +309,7 @@ def _apply_kraus(kraus: tuple[np.ndarray] | Sequence[Any], args: 'ApplyChannelAr
309
309
 
310
310
 
311
311
  def _apply_kraus_single_qubit(
312
- kraus: tuple[Any] | Sequence[Any], args: 'ApplyChannelArgs'
312
+ kraus: tuple[Any] | Sequence[Any], args: ApplyChannelArgs
313
313
  ) -> np.ndarray:
314
314
  """Use slicing to apply single qubit channel. Only for two-level qubits."""
315
315
  zero_left = linalg.slice_for_qubits_equal_to(args.left_axes, 0)
@@ -334,7 +334,7 @@ def _apply_kraus_single_qubit(
334
334
 
335
335
 
336
336
  def _apply_kraus_multi_qubit(
337
- kraus: tuple[Any] | Sequence[Any], args: 'ApplyChannelArgs'
337
+ kraus: tuple[Any] | Sequence[Any], args: ApplyChannelArgs
338
338
  ) -> np.ndarray:
339
339
  """Use numpy's einsum to apply a multi-qubit channel."""
340
340
  qid_shape = tuple(args.target_tensor.shape[i] for i in args.left_axes)
@@ -273,7 +273,7 @@ def apply_mixture(
273
273
  )
274
274
 
275
275
 
276
- def _validate_input(val: Any, args: 'ApplyMixtureArgs') -> tuple[Any, 'ApplyMixtureArgs', bool]:
276
+ def _validate_input(val: Any, args: ApplyMixtureArgs) -> tuple[Any, ApplyMixtureArgs, bool]:
277
277
  """Validate args input and determine if we are operating on a
278
278
  density matrix or a state vector.
279
279
  """
@@ -303,7 +303,7 @@ def _validate_input(val: Any, args: 'ApplyMixtureArgs') -> tuple[Any, 'ApplyMixt
303
303
 
304
304
 
305
305
  def _apply_unitary_strat(
306
- val: Any, args: 'ApplyMixtureArgs', is_density_matrix: bool
306
+ val: Any, args: ApplyMixtureArgs, is_density_matrix: bool
307
307
  ) -> np.ndarray | None:
308
308
  """Attempt to use `apply_unitary` and return the result.
309
309
 
@@ -333,7 +333,7 @@ def _apply_unitary_strat(
333
333
 
334
334
 
335
335
  def _apply_unitary_from_matrix_strat(
336
- val: np.ndarray, args: 'ApplyMixtureArgs', is_density_matrix: bool
336
+ val: np.ndarray, args: ApplyMixtureArgs, is_density_matrix: bool
337
337
  ) -> np.ndarray | None:
338
338
  """Used to enact mixture tuples that are given as (probability, np.ndarray)
339
339
 
@@ -359,7 +359,7 @@ def _apply_unitary_from_matrix_strat(
359
359
 
360
360
 
361
361
  def _apply_mixture_from_mixture_strat(
362
- val: Any, args: 'ApplyMixtureArgs', is_density_matrix: bool
362
+ val: Any, args: ApplyMixtureArgs, is_density_matrix: bool
363
363
  ) -> np.ndarray | None:
364
364
  """Attempt to use unitary matrices in _mixture_ and return the result."""
365
365
  method = getattr(val, '_mixture_', None)
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  from typing import Any
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  from typing import TYPE_CHECKING
@@ -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
-
16
15
  from __future__ import annotations
17
16
 
18
17
  import cirq
@@ -14,7 +14,6 @@
14
14
 
15
15
  """A Gauge transformer for CZ**0.5 and CZ**-0.5 gates."""
16
16
 
17
-
18
17
  from __future__ import annotations
19
18
 
20
19
  from numbers import Real
@@ -14,8 +14,10 @@
14
14
 
15
15
  """Transformers that symbolize operations."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import re
18
- from typing import Hashable, Optional, TYPE_CHECKING
20
+ from typing import Hashable, TYPE_CHECKING
19
21
 
20
22
  import attrs
21
23
  import sympy
@@ -37,11 +39,11 @@ class SymbolizeTag:
37
39
 
38
40
  @transformer_api.transformer
39
41
  def symbolize_single_qubit_gates_by_indexed_tags(
40
- circuit: 'cirq.AbstractCircuit',
42
+ circuit: cirq.AbstractCircuit,
41
43
  *,
42
- context: Optional['cirq.TransformerContext'] = None,
44
+ context: cirq.TransformerContext | None = None,
43
45
  symbolize_tag: SymbolizeTag = SymbolizeTag(prefix="TO-PHXZ"),
44
- ) -> 'cirq.Circuit':
46
+ ) -> cirq.Circuit:
45
47
  """Symbolizes single qubit operations by indexed tags prefixed by symbolize_tag.prefix.
46
48
 
47
49
  Example:
@@ -72,7 +74,7 @@ def symbolize_single_qubit_gates_by_indexed_tags(
72
74
  Copy of the transformed input circuit.
73
75
  """
74
76
 
75
- def _map_func(op: 'cirq.Operation', _):
77
+ def _map_func(op: cirq.Operation, _):
76
78
  """Maps an op with tag `{tag_prefix}_i` to a symbolzied `PhasedXZGate(xi,zi,ai)`."""
77
79
  tags: set[Hashable] = set(op.tags)
78
80
  tag_id: None | int = None
@@ -12,6 +12,8 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ from __future__ import annotations
16
+
15
17
  import pytest
16
18
  import sympy
17
19
 
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-core
3
- Version: 1.6.0.dev20250520183459
3
+ Version: 1.6.0.dev20250520205704
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=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=_yw4RRKmSVMdivsE0OY76zMuGfszlmva9RUSjE8v554,1206
8
- cirq/_version_test.py,sha256=iWTeHzqPI62gfoklh-rr0MZPy7EgzCssOSH5q9vhnLc,155
7
+ cirq/_version.py,sha256=so7mnF1bhJGe7WRkyC17ikUVzKVMcUTZ75WB2hxu7aA,1206
8
+ cirq/_version_test.py,sha256=DG59Z07WSPk9UapX8kT0tF_Yeoj_Q-l7Hfzjn-LI8cs,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
@@ -89,11 +89,11 @@ cirq/contrib/noise_models/noise_models.py,sha256=i1hCLuI4c6DLMQzBenK1ghAvfnrGKCY
89
89
  cirq/contrib/noise_models/noise_models_test.py,sha256=oA7HRMPDi9lv9Lqb8idF9C6Vqjh3KuxD00z5JkE5ybw,10588
90
90
  cirq/contrib/paulistring/__init__.py,sha256=1k2_MYLTMPn8AFoJvSgpN-F-6xgmDjKXRhb-FdDsFoQ,1761
91
91
  cirq/contrib/paulistring/clifford_optimize.py,sha256=VMdivMpQnPQhgqtasce6dOPGx6x6eIZ6Z4f1H666j-I,7859
92
- cirq/contrib/paulistring/clifford_optimize_test.py,sha256=HZBBf13Q6JBLrzulK_--xs-tTiu794tOW2ncYLB3SJ0,3965
92
+ cirq/contrib/paulistring/clifford_optimize_test.py,sha256=8FFLg9gb1HmHHMdXPa-vCr1zyxvgdlciRH8qyfTWQRw,3964
93
93
  cirq/contrib/paulistring/clifford_target_gateset.py,sha256=L-oL0chwBIEQ6zWVPO6ENQJTK7vB5I7RP6i9SkDyr8Q,6330
94
94
  cirq/contrib/paulistring/clifford_target_gateset_test.py,sha256=LUkfj_cahaclu2iByO3YsX-db-DLEWrAxZfxeKuJPdI,8792
95
95
  cirq/contrib/paulistring/optimize.py,sha256=F02c_9nuc8a41XNsA9bzTGaW2kR3hZw-MdaQLse5xj8,2743
96
- cirq/contrib/paulistring/optimize_test.py,sha256=-CHtu1CsRvq0iO_ET2gtNsRy6odUWMXU4RAI7yFft-k,3619
96
+ cirq/contrib/paulistring/optimize_test.py,sha256=FsmwyYFIGyyiO115oYgmCfaSV3De55Azd0_rzsi_xnU,3618
97
97
  cirq/contrib/paulistring/pauli_string_dag.py,sha256=28bUVNsIS9WYKdyYCNIVrkRwqQOKlkpmCacWow6N6D0,1142
98
98
  cirq/contrib/paulistring/pauli_string_dag_test.py,sha256=nH_1h5LQobV9rb5gitLmrvpIwWwrcRmNdUGDAhFMZtI,1168
99
99
  cirq/contrib/paulistring/pauli_string_measurement_with_readout_mitigation.py,sha256=Tz69rtet_u69CpOxERkGjaC0Ty13OTd6THP8tl097No,20057
@@ -107,8 +107,8 @@ cirq/contrib/paulistring/separate_test.py,sha256=mp_ixjxS9-YypnJkgApFzSV0QGJt0SD
107
107
  cirq/contrib/qasm_import/__init__.py,sha256=RKX0vGDC2Pe5rH5rM4ClXdvtrAU16ePFImQpiJtJVNo,744
108
108
  cirq/contrib/qasm_import/_lexer.py,sha256=_XlorbGfEXgsqTZcGbtgfEgaJ6mJ8I51pEjlBsaOT6I,2965
109
109
  cirq/contrib/qasm_import/_lexer_test.py,sha256=L1Deb3FO5urHnXN-nb4FRKpaDTqITTMLBeUu3JFeWaA,6254
110
- cirq/contrib/qasm_import/_parser.py,sha256=i-bUT3Zzge5fHCYHuveamks8OeeC1XLhq9cqJlgQjns,25983
111
- cirq/contrib/qasm_import/_parser_test.py,sha256=92GQEZixq9rK42RqnHHrqOGeKBdrCIWn5RiM5ygKEaY,40303
110
+ cirq/contrib/qasm_import/_parser.py,sha256=Kl6xK6FqHnIyFQToIn4-0ClHgXEvUXJ1ISuDKw-cjI0,27138
111
+ cirq/contrib/qasm_import/_parser_test.py,sha256=D1AhyV9r4XOXjfllCFlnSC8LkEIvqXvnkUOraYHYG40,44355
112
112
  cirq/contrib/qasm_import/exception.py,sha256=DdqXaHmZU1TaxaHqXW23yp9bqXxdxqkq4tErGd9VHj8,731
113
113
  cirq/contrib/qasm_import/qasm.py,sha256=k_uX-ITaxHRcrP87kuUNgudloG_ns0HURJLoyq4scqU,989
114
114
  cirq/contrib/qasm_import/qasm_test.py,sha256=NhGf4U_xYgJ4ZQmkS-5GoLWpJRweT1R38OcgHcau328,1898
@@ -116,7 +116,7 @@ cirq/contrib/qcircuit/__init__.py,sha256=6-pIZQUK3LlPVGiPFI7HJTl2_O1P-Rts0MsdDgQ
116
116
  cirq/contrib/qcircuit/qcircuit_diagram.py,sha256=pwaqM9CERfePRxH6Xx3PtMLVIcN1Z375DYfAhpkDVAs,2780
117
117
  cirq/contrib/qcircuit/qcircuit_diagram_info.py,sha256=iseXGluQb8lWQ9L9mF9uJQMhInFaPWXDOBumX_fj34E,4551
118
118
  cirq/contrib/qcircuit/qcircuit_diagram_info_test.py,sha256=mNeqAKJwzE4sZQEadto8EFuP_UI9ckfMJFzqfBHuYhc,2429
119
- cirq/contrib/qcircuit/qcircuit_pdf.py,sha256=am9X5DsgQ569P2-nKfZn6oOYMbxNaaYCsJ4IyZvCpwg,2486
119
+ cirq/contrib/qcircuit/qcircuit_pdf.py,sha256=IEuq2rQMU9x_NcU8MS9uRc5o-E_BoeJPo8ixLRBH83A,2485
120
120
  cirq/contrib/qcircuit/qcircuit_pdf_test.py,sha256=qiR8GIopgeImoLtGD4vTzp_R3nPRhOg9pUND4Y6gRjs,1122
121
121
  cirq/contrib/qcircuit/qcircuit_test.py,sha256=Q6SqGhxvs2JVYvmT0S4tSNxB-DBUE7bHkrhqUb1cLNo,6125
122
122
  cirq/contrib/quantum_volume/__init__.py,sha256=RF_nbmm9s9A8sLhsnb7aZnuuoeHnsvlRNuoK8nBBW2w,1038
@@ -361,7 +361,7 @@ cirq/ops/qid_util.py,sha256=B2Ilqp4LCDN-Um3lx2GfWq3IelZYicMvFx7hgIQmmhc,2095
361
361
  cirq/ops/qid_util_test.py,sha256=5jy-dxgm_ae9YAPVs7af_Afr2pYNb9R8ON43Zb0Ku20,1097
362
362
  cirq/ops/qubit_manager.py,sha256=5CFtTkkWE5aW4yyFnr2M70_Fw6jNUI-ltTXMVcL9oUc,3549
363
363
  cirq/ops/qubit_manager_test.py,sha256=yCzPLh-HhS1z0FzA2ukxZqkK0iP3pf0zMXObtnOMI6w,3440
364
- cirq/ops/qubit_order.py,sha256=fN5mPlt0uaSa8T0NyJGOgmBXZKHH2r9mzhUkrNnukZs,5511
364
+ cirq/ops/qubit_order.py,sha256=Ekk246AzaeW6w3fNGNhHdGOQbD_DU8KeXl7BMhX-SDM,5497
365
365
  cirq/ops/qubit_order_or_list.py,sha256=vP5MwFI5pbn8WH6eFzwe_sE3EPixRRWGDj0jlbECNRM,1201
366
366
  cirq/ops/qubit_order_test.py,sha256=e8gBGSCHyKu9nJHPwEPVO060uDpJCpO0ok5n6toR0PU,4274
367
367
  cirq/ops/random_gate_channel.py,sha256=i4eg9GA4CF6ZWQRrICa5lfYqvdZzN8oLEWwXHcxRStM,5115
@@ -385,9 +385,9 @@ cirq/ops/wait_gate_test.py,sha256=cBYqPQc339lfwXgdUSl0OD0ZlfsqaPvyrmnArD7ERs8,35
385
385
  cirq/protocols/__init__.py,sha256=JvMKV92kF8qxm8mXNM9iY8TMyn87mwSwaafnvuphcgY,6087
386
386
  cirq/protocols/act_on_protocol.py,sha256=yf8QZwBUG6E2vdkHHZho7-6n2_qtBQJZ9onw6XMAO8w,6912
387
387
  cirq/protocols/act_on_protocol_test.py,sha256=X7GNM9mGPCpWukW9_7kF88g12RdqsWhcniIw5LW1tC4,3215
388
- cirq/protocols/apply_channel_protocol.py,sha256=lrR9s4i73gLzLf0DMntu8ySZADlB8ms-JrK29rCxo6w,15623
388
+ cirq/protocols/apply_channel_protocol.py,sha256=-FkwzW2FKDY713lGOTIJ0yMIPKp3ZzWqLBl_yhmOGdk,15615
389
389
  cirq/protocols/apply_channel_protocol_test.py,sha256=THW95ZzW1y8UtBIuzVJ872wEOZqIcFdPbXocBUzAiWw,10618
390
- cirq/protocols/apply_mixture_protocol.py,sha256=gczZ_0vdgiyjXBDPVQxH2bsG8jk1NtKHQ3XRdrfcQUY,16448
390
+ cirq/protocols/apply_mixture_protocol.py,sha256=bB2EJOrGccuMBuHR4paZnguYavL4KanzTTiLUgzM1eM,16438
391
391
  cirq/protocols/apply_mixture_protocol_test.py,sha256=_ftefdRBYj73OC_m3179VX8U1-xDesAOHu94tx3d-gU,11142
392
392
  cirq/protocols/apply_unitary_protocol.py,sha256=bvqGe_Yt_pnJiVRlj9Kq0_sf557BrA1iUgr8fEJeB9g,29714
393
393
  cirq/protocols/apply_unitary_protocol_test.py,sha256=po1z7a-r4kbfLg7_7XKgFMrsFIzQCFgceCwn-lyBEOA,26172
@@ -993,7 +993,7 @@ cirq/testing/consistent_qasm_test.py,sha256=Z1bfMsgoXwe27RDhruKqBV4eGqTHUOwkP17T
993
993
  cirq/testing/consistent_resolve_parameters.py,sha256=1Vq4GWoZdFOnz8b_M_rFwScR-bcVfctfLWbBLHRO7zs,2010
994
994
  cirq/testing/consistent_specified_has_unitary.py,sha256=R8xFCPoIUZn-4KoUGPHASGfwQ5iqqeLO5qQgT1HB1Xs,1168
995
995
  cirq/testing/consistent_specified_has_unitary_test.py,sha256=CSNOVzVtBXwoyUBLppleg0nRC5KhKXVDwoGVxhnirzs,2597
996
- cirq/testing/consistent_unitary.py,sha256=-5Jrz7OYZGuvoo3KSDi5RwoVcU9WUZPmW07pve91nk8,3285
996
+ cirq/testing/consistent_unitary.py,sha256=8O9xaTEQCUNOn8BsuHnCXcbXI8ZV2DZGiNp1dk55xM0,3284
997
997
  cirq/testing/consistent_unitary_test.py,sha256=yK8fFh2bcmZunUF2lrsTWY5pt9sk6pFKInvMg0MrKZ0,3312
998
998
  cirq/testing/deprecation.py,sha256=FMgdC8sXKXYZl6abKM_6FymzSulhtAewmWnjVWlGF3g,2189
999
999
  cirq/testing/deprecation_test.py,sha256=LC---8mwEnEu4mi_95aJmv-z5lEB1wSFVqX_KVueOT0,2219
@@ -1083,8 +1083,8 @@ cirq/transformers/randomized_measurements.py,sha256=J4c9ZwYRDJ2_X_QzXWds4Qe0t9ZL
1083
1083
  cirq/transformers/randomized_measurements_test.py,sha256=ZfD8QW9Iy7NfidA1Iez9DUuT9HuzyEzFpHF1JNffE-I,2817
1084
1084
  cirq/transformers/stratify.py,sha256=-Kl9y508gRi84Jwh-ZvLAerdpqPBmhAdknxXfVhcUK0,10452
1085
1085
  cirq/transformers/stratify_test.py,sha256=X4h2KMc82N3G6d_qLIP0HTsrDWerWgEXTH_WBPN8nd0,15257
1086
- cirq/transformers/symbolize.py,sha256=1YE-SMa6iR_YTGiKll0iZXp5uuBTOpSVF_UQts6DwVA,3977
1087
- cirq/transformers/symbolize_test.py,sha256=bMQhtvt301uKyQH3tAM_wwVjBmPSZAqGpQH3p-DK5NE,2207
1086
+ cirq/transformers/symbolize.py,sha256=F4ky19Fd81recaSpmvldCmAjbmlEnf9-WxUexAYy9As,3992
1087
+ cirq/transformers/symbolize_test.py,sha256=IF92t0r_mhC48tmCCVJqykXD6ms166n6XfbcSRTrJbY,2243
1088
1088
  cirq/transformers/synchronize_terminal_measurements.py,sha256=lORajz_Qd1RC3baNdrqo5xJcqEWgwPHUfY0VaHk6lxI,3825
1089
1089
  cirq/transformers/synchronize_terminal_measurements_test.py,sha256=sOmAYP3jXSUbUSJO5KKgkLPDWCWxPLUcRTSZ48HaDrA,7858
1090
1090
  cirq/transformers/tag_transformers.py,sha256=WQSjTBRfwuhzYfqe-bbyUA-nEYHAFcNg8jiEn-Uru2U,3526
@@ -1128,12 +1128,12 @@ cirq/transformers/gauge_compiling/cz_gauge_test.py,sha256=MQURH_tIIPxHu7CRWWEdDk
1128
1128
  cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=bXqAEVBXHplnxRMwNA0GrbpHsVLoY-zV0zpeP3VNjJY,18834
1129
1129
  cirq/transformers/gauge_compiling/gauge_compiling_test.py,sha256=JFG7aCe-PxPGZDPCAx82ILu6PX_laFvCDlaabwvL0Kc,5272
1130
1130
  cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py,sha256=NUbcz-tGS58QPohpsmMx0RbB4d79GMSoyVxdL3CPiZc,5060
1131
- cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py,sha256=xJ_h0IXdRh2HEltYxGgYHohVlV7-BaBxCg3YYpGHYGg,1897
1131
+ cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py,sha256=qPcs2BWU-1gOEz0NCLixBLO9I1PVIOLShB7wkprcQZY,1896
1132
1132
  cirq/transformers/gauge_compiling/iswap_gauge.py,sha256=CfW3hgO6AgUB7D6tC8J2XZQw2Ge77LT44BygCzMW4Xc,3536
1133
- cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=t2mQM_79b9WXZqIAo6msrKZuhG4L1HrWxDbt-k9uQVA,902
1133
+ cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=V6g-jyGujMKEzGtOi_OhMxX5oTznGXJi9tCNKI9Qrb8,901
1134
1134
  cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=yhrF4pa1u0-iwYay47_2bZ4xfU323TOdlyazl0U9v4c,1122
1135
1135
  cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py,sha256=FJO8BoP4uA0SqSLXS6bqn3T69SwcBHCQHBwWAkI8YTk,1328
1136
- cirq/transformers/gauge_compiling/sqrt_cz_gauge.py,sha256=XG9MGdgAwzaGIVDjocwENtdV6uWAG8idynlwNGhv0ec,2558
1136
+ cirq/transformers/gauge_compiling/sqrt_cz_gauge.py,sha256=qnVmbXqehhDucg6Cm3VZm5lHez-uttayPSHqL4JHPEA,2557
1137
1137
  cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py,sha256=WXZjPf3SAxZHwWbORnsNPeBu1jHeqBqRkrTPCZiNnAY,1033
1138
1138
  cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py,sha256=kOFHb5GydzeMNwSvDLFuEjc71jHC1HBWxaWinPlrArs,3163
1139
1139
  cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py,sha256=2KJ14je7QNISHQE8GAK0Oy0HisDFiGEYHxCGc0LhRRg,918
@@ -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.dev20250520183459.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
- cirq_core-1.6.0.dev20250520183459.dist-info/METADATA,sha256=1js6vrnUZP2e_XKPIC1Ku70j5Mq-pwGrY2p0F_HqqKk,4857
1225
- cirq_core-1.6.0.dev20250520183459.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1226
- cirq_core-1.6.0.dev20250520183459.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
- cirq_core-1.6.0.dev20250520183459.dist-info/RECORD,,
1223
+ cirq_core-1.6.0.dev20250520205704.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1224
+ cirq_core-1.6.0.dev20250520205704.dist-info/METADATA,sha256=UyrW9LynTW8QOcsYUnD2ts3e-GbBS99NV7k_zIZn9nQ,4857
1225
+ cirq_core-1.6.0.dev20250520205704.dist-info/WHEEL,sha256=zaaOINJESkSfm_4HQVc5ssNzHCPXhJm0kEUakpsEHaU,91
1226
+ cirq_core-1.6.0.dev20250520205704.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1227
+ cirq_core-1.6.0.dev20250520205704.dist-info/RECORD,,