cirq-core 1.4.0.dev20240529184720__py3-none-any.whl → 1.4.0.dev20240529202703__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
@@ -1 +1 @@
1
- __version__ = "1.4.0.dev20240529184720"
1
+ __version__ = "1.4.0.dev20240529202703"
cirq/ops/phased_x_gate.py CHANGED
@@ -28,7 +28,7 @@ from cirq.type_workarounds import NotImplementedType
28
28
 
29
29
  @value.value_equality(manual_cls=True, approximate=True)
30
30
  class PhasedXPowGate(raw_types.Gate):
31
- r"""A gate equivalent to $Z^{p} X^t Z^{-p}$.
31
+ r"""A gate equivalent to $Z^{-p} X^t Z^{p}$ (in time order).
32
32
 
33
33
  The unitary matrix of `cirq.PhasedXPowGate(exponent=t, phase_exponent=p)` is:
34
34
  $$
@@ -27,7 +27,7 @@ if TYPE_CHECKING:
27
27
 
28
28
  @value.value_equality(approximate=True)
29
29
  class PhasedXZGate(raw_types.Gate):
30
- r"""A single qubit gate equivalent to the circuit $Z^z Z^{a} X^x Z^{-a}$.
30
+ r"""A single qubit gate equivalent to the circuit $Z^{-a} X^x Z^{a} Z^z$ (in time order).
31
31
 
32
32
  The unitary matrix of `cirq.PhasedXZGate(x_exponent=x, z_exponent=z, axis_phase_exponent=a)` is:
33
33
  $$
@@ -67,6 +67,22 @@ class PhasedXZGate(raw_types.Gate):
67
67
  self._z_exponent = z_exponent
68
68
  self._axis_phase_exponent = axis_phase_exponent
69
69
 
70
+ @classmethod
71
+ def from_zyz_angles(cls, z0_rad: float, y_rad: float, z1_rad: float) -> 'cirq.PhasedXZGate':
72
+ """Create a PhasedXZGate from ZYZ angles.
73
+
74
+ The returned gate is equivalent to $Rz(z0_rad) Ry(y_rad) Rz(z1_rad)$ (in time order).
75
+ """
76
+ return cls.from_zyz_exponents(z0=z0_rad / np.pi, y=y_rad / np.pi, z1=z1_rad / np.pi)
77
+
78
+ @classmethod
79
+ def from_zyz_exponents(cls, z0: float, y: float, z1: float) -> 'cirq.PhasedXZGate':
80
+ """Create a PhasedXZGate from ZYZ exponents.
81
+
82
+ The returned gate is equivalent to $Z^z0 Y^y Z^z1$ (in time order).
83
+ """
84
+ return PhasedXZGate(axis_phase_exponent=-z0 + 0.5, x_exponent=y, z_exponent=z0 + z1)
85
+
70
86
  def _canonical(self) -> 'cirq.PhasedXZGate':
71
87
  x = self.x_exponent
72
88
  z = self.z_exponent
@@ -34,6 +34,30 @@ def test_eq():
34
34
  eq.add_equality_group(cirq.PhasedXZGate(x_exponent=1, z_exponent=0, axis_phase_exponent=0))
35
35
 
36
36
 
37
+ @pytest.mark.parametrize('z0_rad', [-np.pi / 5, 0, np.pi / 5, np.pi / 4, np.pi / 2, np.pi])
38
+ @pytest.mark.parametrize('y_rad', [0, np.pi / 5, np.pi / 4, np.pi / 2, np.pi])
39
+ @pytest.mark.parametrize('z1_rad', [-np.pi / 5, 0, np.pi / 5, np.pi / 4, np.pi / 2, np.pi])
40
+ def test_from_zyz_angles(z0_rad: float, y_rad: float, z1_rad: float) -> None:
41
+ q = cirq.q(0)
42
+ phxz = cirq.PhasedXZGate.from_zyz_angles(z0_rad, y_rad, z1_rad)
43
+ zyz = cirq.Circuit(cirq.rz(z0_rad).on(q), cirq.ry(y_rad).on(q), cirq.rz(z1_rad).on(q))
44
+ cirq.testing.assert_allclose_up_to_global_phase(
45
+ cirq.unitary(phxz), cirq.unitary(zyz), atol=1e-8
46
+ )
47
+
48
+
49
+ @pytest.mark.parametrize('z0', [-0.2, 0, 0.2, 0.25, 0.5, 1])
50
+ @pytest.mark.parametrize('y', [0, 0.2, 0.25, 0.5, 1])
51
+ @pytest.mark.parametrize('z1', [-0.2, 0, 0.2, 0.25, 0.5, 1])
52
+ def test_from_zyz_exponents(z0: float, y: float, z1: float) -> None:
53
+ q = cirq.q(0)
54
+ phxz = cirq.PhasedXZGate.from_zyz_exponents(z0, y, z1)
55
+ zyz = cirq.Circuit(cirq.Z(q) ** z0, cirq.Y(q) ** y, cirq.Z(q) ** z1)
56
+ cirq.testing.assert_allclose_up_to_global_phase(
57
+ cirq.unitary(phxz), cirq.unitary(zyz), atol=1e-8
58
+ )
59
+
60
+
37
61
  def test_canonicalization():
38
62
  def f(x, z, a):
39
63
  return cirq.PhasedXZGate(x_exponent=x, z_exponent=z, axis_phase_exponent=a)
cirq/ops/raw_types.py CHANGED
@@ -1032,6 +1032,9 @@ class _InverseCompositeGate(Gate):
1032
1032
  def __repr__(self) -> str:
1033
1033
  return f'({self._original!r}**-1)'
1034
1034
 
1035
+ def __str__(self) -> str:
1036
+ return f'{self._original!s}†'
1037
+
1035
1038
 
1036
1039
  def _validate_qid_shape(val: Any, qubits: Sequence['cirq.Qid']) -> None:
1037
1040
  """Helper function to validate qubits for gates and operations.
@@ -759,6 +759,7 @@ def test_inverse_composite_standards():
759
759
  assert cirq.parameter_names(g) == {'a'}
760
760
  assert cirq.resolve_parameters(g, {a: 0}) == Gate(0) ** -1
761
761
  cirq.testing.assert_implements_consistent_protocols(g, global_vals={'C': Gate, 'a': a})
762
+ assert str(g) == 'C(a)†'
762
763
 
763
764
 
764
765
  def test_tagged_act_on():
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.4.0.dev20240529184720
3
+ Version: 1.4.0.dev20240529202703
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,7 +4,7 @@ cirq/_compat_test.py,sha256=Qq3ZcfgD-Nb81cEppQdJqhAyrVqXKtfXZYGXT0p-Wh0,34718
4
4
  cirq/_doc.py,sha256=yDyWUD_2JDS0gShfGRb-rdqRt9-WeL7DhkqX7np0Nko,2879
5
5
  cirq/_import.py,sha256=p9gMHJscbtDDkfHOaulvd3Aer0pwUF5AXpL89XR8dNw,8402
6
6
  cirq/_import_test.py,sha256=6K_v0riZJXOXUphHNkGA8MY-JcmGlezFaGmvrNhm3OQ,1015
7
- cirq/_version.py,sha256=xZcPtVITwmxLT5re7_EAk-JBZ22Lii40HVcbE1MTtyE,40
7
+ cirq/_version.py,sha256=7IbSMFnEONT7hgMVyPqEsw4aeKZR1ioYToO-gnagPd0,40
8
8
  cirq/_version_test.py,sha256=yYS6xm5-nuBRQJa9R3n41WdvFtVyY7Lb5Q8bea3VgBI,133
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=ytePZtNZgKjOF2NiVpUTuotB-JKZmQNOFIFdvXqsxHw,13271
@@ -343,10 +343,10 @@ cirq/ops/permutation_gate.py,sha256=5xTXmnjFF3h8kgWV4wDnHBe4foeeqwEm-69I38WmK3k,
343
343
  cirq/ops/permutation_gate_test.py,sha256=SwXRgsZNLn5jnGhfcKPJ0J0CIssNzElbFaqylV2TXD8,3281
344
344
  cirq/ops/phased_iswap_gate.py,sha256=8zRuD3uvMt4OFegD9zpEM-foJYbZEYBTIApShUk0BaI,8977
345
345
  cirq/ops/phased_iswap_gate_test.py,sha256=oH3RQ8tlSD0sU5Cf3M0uR92y3M1Xd7Yk3ayOoca9Neg,6708
346
- cirq/ops/phased_x_gate.py,sha256=Cq6Dw9TSj5aKZkDkc4NY6JsPwKFSMTSX4QIfiAvbTZQ,9964
346
+ cirq/ops/phased_x_gate.py,sha256=QCDhn4tDm_zhjorYWLpP5xOYNByXiaT35nOspJWt5vY,9980
347
347
  cirq/ops/phased_x_gate_test.py,sha256=IpY-Z-MsqtYbyIEdxWu1NqgAJF2B7nddxPc2Hxafr4s,10202
348
- cirq/ops/phased_x_z_gate.py,sha256=eHYMyPiDhlEyzphJDnaTeLdRn96Tns1VfiYv6FtPShU,10812
349
- cirq/ops/phased_x_z_gate_test.py,sha256=8PCwOgGGWL32QIR8m1kBd5JG3Mq9BMDeeVD0aPk1E90,9541
348
+ cirq/ops/phased_x_z_gate.py,sha256=5JhVE5TReg7AKy3hhS2mE1UdvIXFsScF56e8mD15mmw,11534
349
+ cirq/ops/phased_x_z_gate_test.py,sha256=KK5-FD5zoaqZkw7p6UKxFddzaFWoxnQnE8LpCiKtIk8,10690
350
350
  cirq/ops/projector.py,sha256=isDlNLR8YS5CxsVCihtRAgfKZXFFQxk7kuFXY14t8ys,5690
351
351
  cirq/ops/projector_test.py,sha256=Wq7ddj-PV30yUXJxJoT3XIw2sIUC1AilnZ9m9N5Ejr8,9063
352
352
  cirq/ops/qid_util.py,sha256=SxyoMy_s070lcqXV7ny6vE8pp082OrTjBtawZtHOhXs,2071
@@ -358,8 +358,8 @@ cirq/ops/qubit_order_or_list.py,sha256=WVnhQcOYCgAhiB4t47Kji-pN1tnvs--X5deCQwwGV
358
358
  cirq/ops/qubit_order_test.py,sha256=B9xMIxlaI7YjRUNA6AkHJuUCFejGYw-lT7ZaSl31yTU,4238
359
359
  cirq/ops/random_gate_channel.py,sha256=gKDqZa6AwdCIuuh2UOvO5oxCdGRDOInA7fI3ZLQ-LTY,5121
360
360
  cirq/ops/random_gate_channel_test.py,sha256=U3EAaAlCZkgFIYxqwcSkPsaVGrKA2PSeG_DK2ou--AE,8606
361
- cirq/ops/raw_types.py,sha256=Un3C83tAsHHyXXrAWZSeaKunLITohjt6vTRGmAKAAII,39891
362
- cirq/ops/raw_types_test.py,sha256=r0Dpaw5xugvKltoX6fesB-ZCbsvOXTvqQJsEsxJNWmQ,33453
361
+ cirq/ops/raw_types.py,sha256=XJcbvBc5SgGELEk7LSnjPGVpq6OLOCoZt0FIzOCjBbc,39962
362
+ cirq/ops/raw_types_test.py,sha256=RWUiB2TypXxbDTVaetQ7h-buGScUcQgY6YsFkmodZGY,33484
363
363
  cirq/ops/state_preparation_channel.py,sha256=PjVtoLbjBAy_XqnFAY40Am-NifeuCFVVLW6RJxph5sQ,4778
364
364
  cirq/ops/state_preparation_channel_test.py,sha256=yKUvLw_ft6cvIgRJcFQ779wZS-V6V-pzQq-rZRWdCmU,5922
365
365
  cirq/ops/swap_gates.py,sha256=9eJMGyOiA8W9k2xJ_w5PaLOCHGvB6C4T2RLddIZ5qE8,11601
@@ -1175,8 +1175,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1175
1175
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1176
1176
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1177
1177
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1178
- cirq_core-1.4.0.dev20240529184720.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
- cirq_core-1.4.0.dev20240529184720.dist-info/METADATA,sha256=3Nh2D7K3TVUBr6MEltWgsGZbTG8tmgZVyJqVvuA0UT0,1998
1180
- cirq_core-1.4.0.dev20240529184720.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
- cirq_core-1.4.0.dev20240529184720.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
- cirq_core-1.4.0.dev20240529184720.dist-info/RECORD,,
1178
+ cirq_core-1.4.0.dev20240529202703.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1179
+ cirq_core-1.4.0.dev20240529202703.dist-info/METADATA,sha256=3DWpdJG-PjDXh4MbUwUADOjPUXUpmRgbiNjgMJzyZlE,1998
1180
+ cirq_core-1.4.0.dev20240529202703.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
1181
+ cirq_core-1.4.0.dev20240529202703.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1182
+ cirq_core-1.4.0.dev20240529202703.dist-info/RECORD,,