cirq-core 1.5.0.dev20250107200829__py3-none-any.whl → 1.5.0.dev20250108145717__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.dev20250107200829"
31
+ __version__ = "1.5.0.dev20250108145717"
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.dev20250107200829"
6
+ assert cirq.__version__ == "1.5.0.dev20250108145717"
cirq/ops/identity.py CHANGED
@@ -135,6 +135,8 @@ class IdentityGate(raw_types.Gate):
135
135
  _rmul_with_qubits = _mul_with_qubits
136
136
 
137
137
  def _circuit_diagram_info_(self, args) -> Tuple[str, ...]:
138
+ if self.num_qubits() <= 0:
139
+ return NotImplemented
138
140
  return ('I',) * self.num_qubits()
139
141
 
140
142
  def _qasm_(self, args: 'cirq.QasmArgs', qubits: Tuple['cirq.Qid', ...]) -> Optional[str]:
cirq/ops/identity_test.py CHANGED
@@ -214,3 +214,21 @@ def test_identity_commutes():
214
214
  assert cirq.commutes(cirq.I, cirq.X)
215
215
  with pytest.raises(TypeError):
216
216
  cirq.commutes(cirq.I, "Gate")
217
+
218
+
219
+ def test_identity_diagram():
220
+ cirq.testing.assert_has_diagram(
221
+ cirq.Circuit(cirq.IdentityGate(3).on_each(cirq.LineQubit.range(3))),
222
+ """
223
+ 0: ───I───
224
+
225
+ 1: ───I───
226
+
227
+ 2: ───I───
228
+ """,
229
+ )
230
+ cirq.testing.assert_has_diagram(
231
+ cirq.Circuit(cirq.IdentityGate(0)()),
232
+ """
233
+ I(0)""",
234
+ )
@@ -342,7 +342,7 @@ def _op_info_with_fallback(
342
342
  rows: List[LabelEntity] = list(op.qubits)
343
343
  if args.label_map is not None:
344
344
  rows += protocols.measurement_keys_touched(op) & args.label_map.keys()
345
- if info is not None:
345
+ if info is not None and info.wire_symbols:
346
346
  if max(1, len(rows)) != len(info.wire_symbols):
347
347
  raise ValueError(f'Wanted diagram info from {op!r} for {rows!r}) but got {info!r}')
348
348
  return info
@@ -118,6 +118,7 @@ class SameGateGauge(Gauge):
118
118
  default=(), converter=lambda g: (g,) if isinstance(g, ops.Gate) else tuple(g)
119
119
  )
120
120
  swap_qubits: bool = False
121
+ support_sweep: bool = False
121
122
 
122
123
  def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
123
124
  return ConstantGauge(
@@ -127,6 +128,7 @@ class SameGateGauge(Gauge):
127
128
  post_q0=self.post_q0,
128
129
  post_q1=self.post_q1,
129
130
  swap_qubits=self.swap_qubits,
131
+ support_sweep=self.support_sweep,
130
132
  )
131
133
 
132
134
 
@@ -332,6 +334,13 @@ def _parameterize(num_qubits: int, symbol_id: int) -> Dict[str, sympy.Symbol]:
332
334
  def _gate_sequence_to_phxz_params(
333
335
  gates: Tuple[ops.Gate, ...], xza_by_symbols: Dict[str, sympy.Symbol]
334
336
  ) -> Dict[str, float]:
337
+ identity_gate_in_phxz = {
338
+ str(xza_by_symbols["x_exponent"]): 0.0,
339
+ str(xza_by_symbols["z_exponent"]): 0.0,
340
+ str(xza_by_symbols["axis_phase_exponent"]): 0.0,
341
+ }
342
+ if not gates:
343
+ return identity_gate_in_phxz
335
344
  for gate in gates:
336
345
  if not has_unitary(gate) or gate.num_qubits() != 1:
337
346
  raise ValueError(
@@ -347,11 +356,7 @@ def _gate_sequence_to_phxz_params(
347
356
  or ops.I
348
357
  )
349
358
  if phxz is ops.I: # Identity gate
350
- return {
351
- str(xza_by_symbols["x_exponent"]): 0.0,
352
- str(xza_by_symbols["z_exponent"]): 0.0,
353
- str(xza_by_symbols["axis_phase_exponent"]): 0.0,
354
- }
359
+ return identity_gate_in_phxz
355
360
  # Check the gate type, needs to be a PhasedXZ gate.
356
361
  if not isinstance(phxz, ops.PhasedXZGate):
357
362
  raise ValueError("Failed to convert the gate sequence to a PhasedXZ gate.")
@@ -56,6 +56,7 @@ class RZRotation(Gauge):
56
56
  pre_q1=n_rz if flip_diangonal else rz,
57
57
  post_q0=rz if flip_diangonal else n_rz,
58
58
  post_q1=n_rz,
59
+ support_sweep=True,
59
60
  )
60
61
 
61
62
  def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
@@ -88,7 +89,12 @@ class XYRotation(Gauge):
88
89
  xy_a = self._xy(a)
89
90
  xy_b = self._xy(b)
90
91
  return ConstantGauge(
91
- two_qubit_gate=ops.ISWAP, pre_q0=xy_a, pre_q1=xy_b, post_q0=xy_b, post_q1=xy_a
92
+ two_qubit_gate=ops.ISWAP,
93
+ pre_q0=xy_a,
94
+ pre_q1=xy_b,
95
+ post_q0=xy_b,
96
+ post_q1=xy_a,
97
+ support_sweep=True,
92
98
  )
93
99
 
94
100
  def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
@@ -21,3 +21,4 @@ from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTe
21
21
  class TestISWAPGauge(GaugeTester):
22
22
  two_qubit_gate = cirq.ISWAP
23
23
  gauge_transformer = ISWAPGaugeTransformer
24
+ sweep_must_pass = True
@@ -23,8 +23,8 @@ from cirq import ops
23
23
 
24
24
  SpinInversionGaugeSelector = GaugeSelector(
25
25
  gauges=[
26
- SameGateGauge(pre_q0=ops.X, post_q0=ops.X, pre_q1=ops.X, post_q1=ops.X),
27
- SameGateGauge(),
26
+ SameGateGauge(pre_q0=ops.X, post_q0=ops.X, pre_q1=ops.X, post_q1=ops.X, support_sweep=True),
27
+ SameGateGauge(support_sweep=True),
28
28
  ]
29
29
  )
30
30
 
@@ -20,18 +20,22 @@ from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTe
20
20
  class TestSpinInversionGauge_0(GaugeTester):
21
21
  two_qubit_gate = cirq.ZZ
22
22
  gauge_transformer = SpinInversionGaugeTransformer
23
+ sweep_must_pass = True
23
24
 
24
25
 
25
26
  class TestSpinInversionGauge_1(GaugeTester):
26
27
  two_qubit_gate = cirq.ZZ**0.1
27
28
  gauge_transformer = SpinInversionGaugeTransformer
29
+ sweep_must_pass = True
28
30
 
29
31
 
30
32
  class TestSpinInversionGauge_2(GaugeTester):
31
33
  two_qubit_gate = cirq.ZZ**-1
32
34
  gauge_transformer = SpinInversionGaugeTransformer
35
+ sweep_must_pass = True
33
36
 
34
37
 
35
38
  class TestSpinInversionGauge_3(GaugeTester):
36
39
  two_qubit_gate = cirq.ZZ**0.3
37
40
  gauge_transformer = SpinInversionGaugeTransformer
41
+ sweep_must_pass = True
@@ -49,7 +49,12 @@ class RZRotation(Gauge):
49
49
  rz = ops.rz(theta)
50
50
  n_rz = ops.rz(-theta)
51
51
  return ConstantGauge(
52
- two_qubit_gate=ops.SQRT_ISWAP, pre_q0=rz, pre_q1=rz, post_q0=n_rz, post_q1=n_rz
52
+ two_qubit_gate=ops.SQRT_ISWAP,
53
+ pre_q0=rz,
54
+ pre_q1=rz,
55
+ post_q0=n_rz,
56
+ post_q1=n_rz,
57
+ support_sweep=True,
53
58
  )
54
59
 
55
60
  def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
@@ -80,7 +85,12 @@ class XYRotation(Gauge):
80
85
  def _xy_gauge(self, theta: float) -> ConstantGauge:
81
86
  xy = self._xy(theta)
82
87
  return ConstantGauge(
83
- two_qubit_gate=ops.SQRT_ISWAP, pre_q0=xy, pre_q1=xy, post_q0=xy, post_q1=xy
88
+ two_qubit_gate=ops.SQRT_ISWAP,
89
+ pre_q0=xy,
90
+ pre_q1=xy,
91
+ post_q0=xy,
92
+ post_q1=xy,
93
+ support_sweep=True,
84
94
  )
85
95
 
86
96
  def sample(self, gate: ops.Gate, prng: np.random.Generator) -> ConstantGauge:
@@ -20,3 +20,4 @@ from cirq.transformers.gauge_compiling.gauge_compiling_test_utils import GaugeTe
20
20
  class TestSqrtISWAPGauge(GaugeTester):
21
21
  two_qubit_gate = cirq.SQRT_ISWAP
22
22
  gauge_transformer = SqrtISWAPGaugeTransformer
23
+ sweep_must_pass = True
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20250107200829
3
+ Version: 1.5.0.dev20250108145717
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=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=1IzZqJ3LoFfsJFj3Rt9M3_lbHSOUPBNMgOkx6v1gmEM,1206
8
- cirq/_version_test.py,sha256=zgzaU8RHGLApG0krjzBLlivJwyGBOD9vi4-P2au95VY,147
7
+ cirq/_version.py,sha256=mrNZoT__zOoO0SXNtxmaSeEDXqN2HC3dz_uS5PXC2Tk,1206
8
+ cirq/_version_test.py,sha256=uumqbiuCIdPtZXdGe8RKQj8G7FdH7ub-AqKj2vq-TXo,147
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=03MVo6Y-UYrzt9CKHmwpiBLN2ixL6uSU-OWnKZXfG7k,13302
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -304,8 +304,8 @@ cirq/ops/global_phase_op.py,sha256=4qYUov6BnBql2_yqUHI9DE60fLiLmCsKI9ZkfMLRRyo,4
304
304
  cirq/ops/global_phase_op_test.py,sha256=FjtUsohIYabTtiGytvPQw9Rzkqd6dlT7qrj4oltDbTI,9814
305
305
  cirq/ops/greedy_qubit_manager.py,sha256=O9qY8GB1KGxm3B7JEjq50sGVD51bNwTSupJpi3WUeAc,4039
306
306
  cirq/ops/greedy_qubit_manager_test.py,sha256=iVZDKes-r08raTiJHpYNmP-Dp89ok3hIU-QboL2BHdw,3300
307
- cirq/ops/identity.py,sha256=Lag4bK_QfDebiJD2xN5yM46IXn9KsoF3Afzs8c4eluw,5818
308
- cirq/ops/identity_test.py,sha256=-z5TjxNaD3_z73nGdR3RbHt6ytaYOAyYggCzwZtlQDw,7568
307
+ cirq/ops/identity.py,sha256=FtsDwxqmnHenOD0H1H5p6TGgDQ76LZfk3Z_2vpijNDY,5887
308
+ cirq/ops/identity_test.py,sha256=OIrm8v4wBVq8bbAGZ-f5TERt8Hl6aD1bL8iHCOEhzNo,7939
309
309
  cirq/ops/kraus_channel.py,sha256=tCPAEzr_GAL5vTwI43rBoiOnT04l-ebZanuuEuYWDo8,5085
310
310
  cirq/ops/kraus_channel_test.py,sha256=qH2Y9cngXzKCabd-Mq5xBYcM_wyL8c6KkrXw8kZr7Dc,4726
311
311
  cirq/ops/linear_combinations.py,sha256=WqQ2STxGpgO6KUj4yc6LfSI9OWCdzlmWMt6BkTkf2wA,39694
@@ -386,7 +386,7 @@ cirq/protocols/apply_unitary_protocol.py,sha256=giJwec5XCEt5s0_uyNEuhGBlcDeJymPv
386
386
  cirq/protocols/apply_unitary_protocol_test.py,sha256=ajjHvcBBv5n8Qh_hMPZkdsOvy1xJ774q4kuC25DJnKM,26136
387
387
  cirq/protocols/approximate_equality_protocol.py,sha256=P5mWl9BWGpobw3K7iAoupFPSqO9V2yG82rfQHWTClmM,6313
388
388
  cirq/protocols/approximate_equality_protocol_test.py,sha256=BYGw5iNU3lsdH5BUDPnqd9xfvfIo9-j5j0og_yXCQyY,9174
389
- cirq/protocols/circuit_diagram_info_protocol.py,sha256=14hKWu2oMh65UQehXyLLBDh88ZMSijdqFUVjbhqLzDE,15989
389
+ cirq/protocols/circuit_diagram_info_protocol.py,sha256=R8LiAgmCZjuFT7_8ZGQ6Mvl2H0rOGRkB5DaSgM6N3hA,16011
390
390
  cirq/protocols/circuit_diagram_info_protocol_test.py,sha256=dSvjaGEbMGuSrs4kpFen5Z-_dC1JzPvl27Dg47di4A0,10415
391
391
  cirq/protocols/commutes_protocol.py,sha256=qdJT8x7CtTILbt5zjmftKtHGRgSKHYwYzGC2WUy08Js,7454
392
392
  cirq/protocols/commutes_protocol_test.py,sha256=h0Lky4jrs7Hxrh4MeHxmxNciuofKGGZ2eC-ceWP8wKU,5849
@@ -1094,18 +1094,18 @@ cirq/transformers/analytical_decompositions/two_qubit_to_sqrt_iswap_test.py,sha2
1094
1094
  cirq/transformers/gauge_compiling/__init__.py,sha256=ZF53ZtYRJeKsVJYjKc_QrAqE1pyd8FFmmb6Wo8JdgQs,1385
1095
1095
  cirq/transformers/gauge_compiling/cz_gauge.py,sha256=pJ41uVaUltigKLIayxr0XMqTYEs0zUDnaWD-tp65pPk,4198
1096
1096
  cirq/transformers/gauge_compiling/cz_gauge_test.py,sha256=sHEgEEI_z9-Ka5ChN2JmtoYcEHhNYHysOjGJzaaKkoA,881
1097
- cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=MyzYcgr0vl0pzOq41jkzmrM6COsDg7e2iU_xQcUoQ20,15063
1097
+ cirq/transformers/gauge_compiling/gauge_compiling.py,sha256=kNIJwyGchc1eVrsb1tzSkwm01_PVDYyLSL56mG8xlcA,15230
1098
1098
  cirq/transformers/gauge_compiling/gauge_compiling_test.py,sha256=Nm0Uxqrq1Y5puQep9UpKXK2zg9a3Dx2NSFArIxeawUg,4444
1099
1099
  cirq/transformers/gauge_compiling/gauge_compiling_test_utils.py,sha256=7RNZ6-xQ1iKjoNWTokgok7xTCeAnrQUzbpdBhdJZEfY,4933
1100
1100
  cirq/transformers/gauge_compiling/gauge_compiling_test_utils_test.py,sha256=cWEAP1EWbpHNp7wQPXLyT413raoG3aIg8aFod_aXAtQ,2340
1101
- cirq/transformers/gauge_compiling/iswap_gauge.py,sha256=UGJ_061h65Rfgb9LWREjxC8OSt01ZqP9TGnacL8VAuk,3500
1102
- cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=HEIIwKlX5ixau1e_etSUj5NvYOVTT-Gc3kuHcyKAeJ4,866
1103
- cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=gfjSlQdo13GfBPlrkQoHPWWzouiV7yYr7JAaB85NSGY,1086
1104
- cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py,sha256=FJwl11VPNXkf_v0WjCg9VxNKAplZ_5bZR7guOfnK-aI,1292
1101
+ cirq/transformers/gauge_compiling/iswap_gauge.py,sha256=W2g2DXhN1OQbVL1UxBjvZa3YsRPMFAiaC-tvxKImSHU,3613
1102
+ cirq/transformers/gauge_compiling/iswap_gauge_test.py,sha256=HoeJgSJSrr3ARXDPP9uOb5z4fgvR94snTWGfqG7-yuE,893
1103
+ cirq/transformers/gauge_compiling/spin_inversion_gauge.py,sha256=wpZx2-FbBt2Eq9ORUzMYPqtuJcHkU_5PTcQFDRfwSBo,1124
1104
+ cirq/transformers/gauge_compiling/spin_inversion_gauge_test.py,sha256=eQ65i1GovnL2-VmPumcFKMIjqE0Pee1PdmsO0XDGmW4,1400
1105
1105
  cirq/transformers/gauge_compiling/sqrt_cz_gauge.py,sha256=32OGTcYT3tBFEQ1GQlrssc1wtwCcSvk4ZC0I1XD1QXg,1869
1106
1106
  cirq/transformers/gauge_compiling/sqrt_cz_gauge_test.py,sha256=RwjadOOJfa2Qf7iryTIMJLPzeDMNqFkP6Tewjq68gJI,997
1107
- cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py,sha256=dqQa-UWq31bE_jF3KMhU76sND5GuqTpEp9-wVuXdWVM,3126
1108
- cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py,sha256=0CLZoLw-WK3aKEIoaKBrQZ-qvaprOVLad-dVyWFmSiU,882
1107
+ cirq/transformers/gauge_compiling/sqrt_iswap_gauge.py,sha256=VnlO4eqy5Yx-cE_EO0JSV2iccyJnrp7WWgzPiF_cJGg,3288
1108
+ cirq/transformers/gauge_compiling/sqrt_iswap_gauge_test.py,sha256=n0so4a7TLvpL5CelBUExpA0dgGvfAVxLsqLxRpKqFYE,909
1109
1109
  cirq/transformers/heuristic_decompositions/__init__.py,sha256=_LEidXfFkmJicQapJVR1etyH1fLJ3ZwtBgq2M2_ECZI,926
1110
1110
  cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils.py,sha256=j9bbiIbC2rvwG830gTTf9zr9C7RVA5Ilhka_ZNF-N7w,10785
1111
1111
  cirq/transformers/heuristic_decompositions/gate_tabulation_math_utils_test.py,sha256=N02nlz7tISYVArvWNILwg-hnDB5Y9PCHbwIxk42Afv8,1534
@@ -1189,8 +1189,8 @@ cirq/work/sampler.py,sha256=bE5tmVkcR6cZZMLETxDfHehdsYUMbx2RvBeIBetehI4,19187
1189
1189
  cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
1190
1190
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1191
1191
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1192
- cirq_core-1.5.0.dev20250107200829.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1193
- cirq_core-1.5.0.dev20250107200829.dist-info/METADATA,sha256=VzVrY8j_ZQHx2jXuVVV3R_-kK96AmwzSyVdpzxeciP8,1992
1194
- cirq_core-1.5.0.dev20250107200829.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1195
- cirq_core-1.5.0.dev20250107200829.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1196
- cirq_core-1.5.0.dev20250107200829.dist-info/RECORD,,
1192
+ cirq_core-1.5.0.dev20250108145717.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1193
+ cirq_core-1.5.0.dev20250108145717.dist-info/METADATA,sha256=E6aNfMcs-MODEH0cMTp0NvaUteW2iixdd8yJFQFFBp4,1992
1194
+ cirq_core-1.5.0.dev20250108145717.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1195
+ cirq_core-1.5.0.dev20250108145717.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1196
+ cirq_core-1.5.0.dev20250108145717.dist-info/RECORD,,