cirq-core 1.4.0.dev20240228192904__py3-none-any.whl → 1.4.0.dev20240305032422__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.dev20240228192904"
1
+ __version__ = "1.4.0.dev20240305032422"
@@ -293,7 +293,11 @@ class QasmOutput:
293
293
  output(f'creg {meas_id}[{len(meas.qubits)}];\n')
294
294
  else:
295
295
  output(f'creg {meas_id}[{len(meas.qubits)}]; // Measurement: {comment}\n')
296
- output_line_gap(2)
296
+ # In OpenQASM 2.0, the transformation of global phase gates is ignored.
297
+ # Therefore, no newline is created when the operations contained in
298
+ # a circuit consist only of global phase gates.
299
+ if any(not isinstance(op.gate, ops.GlobalPhaseGate) for op in self.operations):
300
+ output_line_gap(2)
297
301
 
298
302
  # Operations
299
303
  self._write_operations(self.operations, output, output_line_gap)
@@ -191,6 +191,19 @@ ry(pi*-0.25) q[0];
191
191
  )
192
192
 
193
193
 
194
+ def test_qasm_global_pahse():
195
+ output = cirq.QasmOutput((cirq.global_phase_operation(np.exp(1j * 5))), ())
196
+ assert (
197
+ str(output)
198
+ == """OPENQASM 2.0;
199
+ include "qelib1.inc";
200
+
201
+
202
+ // Qubits: []
203
+ """
204
+ )
205
+
206
+
194
207
  def test_precision():
195
208
  (q0,) = _make_qubits(1)
196
209
  output = cirq.QasmOutput((cirq.X(q0) ** 0.1234567,), (q0,), precision=3)
@@ -15,6 +15,7 @@
15
15
  """Basic types defining qubits, gates, and operations."""
16
16
 
17
17
  import re
18
+ import warnings
18
19
  from typing import (
19
20
  AbstractSet,
20
21
  Any,
@@ -35,7 +36,7 @@ from typing_extensions import Self
35
36
 
36
37
  import numpy as np
37
38
 
38
- from cirq import protocols, value
39
+ from cirq import ops, protocols, value
39
40
  from cirq.ops import raw_types, gate_features, control_values as cv
40
41
  from cirq.type_workarounds import NotImplementedType
41
42
 
@@ -348,6 +349,14 @@ class GateOperation(raw_types.Operation):
348
349
  return self.gate._rmul_with_qubits(self._qubits, other)
349
350
 
350
351
  def _qasm_(self, args: 'protocols.QasmArgs') -> Optional[str]:
352
+ if isinstance(self.gate, ops.GlobalPhaseGate):
353
+ warnings.warn(
354
+ "OpenQASM 2.0 does not support global phase."
355
+ "Since the global phase does not affect the measurement results, "
356
+ "the conversion to QASM is disregarded."
357
+ )
358
+ return ""
359
+
351
360
  return protocols.qasm(self.gate, args=args, qubits=self.qubits, default=None)
352
361
 
353
362
  def _equal_up_to_global_phase_(
@@ -42,6 +42,7 @@ def assert_qasm_is_consistent_with_unitary(val: Any):
42
42
  if isinstance(val, ops.Operation):
43
43
  qubits: Sequence[ops.Qid] = val.qubits
44
44
  op = val
45
+ gate = val.gate
45
46
  elif isinstance(val, ops.Gate):
46
47
  qid_shape = protocols.qid_shape(val)
47
48
  remaining_shape = list(qid_shape)
@@ -52,9 +53,14 @@ def assert_qasm_is_consistent_with_unitary(val: Any):
52
53
  remaining_shape.pop(i)
53
54
  qubits = devices.LineQid.for_qid_shape(remaining_shape)
54
55
  op = val.on(*qubits)
56
+ gate = val
55
57
  else:
56
58
  raise NotImplementedError(f"Don't know how to test {val!r}")
57
59
 
60
+ if isinstance(gate, ops.GlobalPhaseGate):
61
+ # OpenQASM 2.0 does not support global phase gates.
62
+ return
63
+
58
64
  args = protocols.QasmArgs(qubit_id_map={q: f'q[{i}]' for i, q in enumerate(qubits)})
59
65
  qasm = protocols.qasm(op, args=args, default=None)
60
66
  if qasm is None:
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.4.0.dev20240228192904
3
+ Version: 1.4.0.dev20240305032422
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=g_3NGywY8O4QCwOlRZmk1mi4CPOnfqC-Lsq_HhV34gY,40
7
+ cirq/_version.py,sha256=b7swci8eu3zgT7ZzPHpT4QjC9ByfqBK5ry6amA-Gg4o,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=S0HaPOCUIck-vNSQlS6KxnQtle6w-2dGuSxkUbJQY9Y,13168
@@ -29,8 +29,8 @@ cirq/circuits/moment.py,sha256=DosJv32UEyT8ugdyIplI8qbfOQUmCWSinCwMT-pFDBA,25784
29
29
  cirq/circuits/moment_test.py,sha256=SAZR-BxNiFaYaPLKLN59LCBqxvBMrVJWa-js1kfhOZA,26905
30
30
  cirq/circuits/optimization_pass.py,sha256=uw3ne0-ebZo6GNjwfQMuQ3b5u9RCgyaXRfhpbljlxao,6468
31
31
  cirq/circuits/optimization_pass_test.py,sha256=eQB0NBJ9EvqjgSFGQMgaHIh5niQhksdnvqSXhsj3nOg,5947
32
- cirq/circuits/qasm_output.py,sha256=DvERpI5X7F57raJRcuUBe06YWCObB1KLHkBbu1DF8fg,11728
33
- cirq/circuits/qasm_output_test.py,sha256=xu_LH3bY-8XAK5vDP0ulcEehVrBsYb6XWZ8o2d3C47U,12254
32
+ cirq/circuits/qasm_output.py,sha256=3cN7m0-pztNqkJTzLZEWt0aD-CC008WItz94Abut9H4,12032
33
+ cirq/circuits/qasm_output_test.py,sha256=pzklIAWUJASn1y_B1wZfJkcfjqU7q6uN61thqkfuy5c,12475
34
34
  cirq/circuits/text_diagram_drawer.py,sha256=ctZUG5fk2pf4XswHTJG4kteQYzzH0TefL9JWUagLJvc,17232
35
35
  cirq/circuits/text_diagram_drawer_test.py,sha256=2bSoBIeQajRi0aQxqYDpbMlT2eqpx_f-Cmg9XO6A9Jk,10750
36
36
  cirq/contrib/__init__.py,sha256=q8NwuMeqIzKaLsO9L6eKuZbGpldBsvaiIPWou37sZjo,1006
@@ -295,7 +295,7 @@ cirq/ops/fsim_gate.py,sha256=H9Yz2XkUiNk0Mv6aJxL80yxwjvwrB9mO0zDUGF5LDcs,18695
295
295
  cirq/ops/fsim_gate_test.py,sha256=owW1VpXntJqxlzhtppnyfaS9gQKFNA6UzCHksgPHaHU,25165
296
296
  cirq/ops/gate_features.py,sha256=414mSi3kgKSwLOeAG_WEZKn8ZMaLtOowed7os1qSnM4,1049
297
297
  cirq/ops/gate_features_test.py,sha256=mnlqJnSpllcOnTUdvmUs_ssnPRhAIgHhKIAK2Z86Dfg,2347
298
- cirq/ops/gate_operation.py,sha256=7Xjhi9dfse1by2TL3aOPiVL8cXyk8ZXfeO57AHe8ajk,13394
298
+ cirq/ops/gate_operation.py,sha256=Fa3O_-bLGAtFznYv-b_RWAn2X4JgvM3yGbqbLcsJkgM,13736
299
299
  cirq/ops/gate_operation_test.py,sha256=ftd-GZxvOtzFS1L153K89_PV1volGroU7G5nFGp9afE,17507
300
300
  cirq/ops/gateset.py,sha256=Tx1CIlve0RhnX9jHZsCVw7EHtfC6b3drbBncmCEtcsQ,21634
301
301
  cirq/ops/gateset_test.py,sha256=BY5UJ1k3NC0jz0d4yocyO1qcQU6e4UbN9mapWE7z7AM,16361
@@ -951,7 +951,7 @@ cirq/testing/consistent_phase_by.py,sha256=oSZcZnKMOIJnBS0HgYi-8aRaVJmHGgI--WAUG
951
951
  cirq/testing/consistent_phase_by_test.py,sha256=YbI0n0FpWpBkbgYp0-yGZSeesDZEst0cmYtXgJE2LQY,3273
952
952
  cirq/testing/consistent_protocols.py,sha256=ZRLuaquTuSGhI_KaOdXa0ooDJC3gOO3ykfciKiHqhrU,7773
953
953
  cirq/testing/consistent_protocols_test.py,sha256=PFp9DF5b2Il2lj1NW70JKPxa5JbG4I_hn-ftis10UD4,10020
954
- cirq/testing/consistent_qasm.py,sha256=zCci5xgvjFmBU8G_j-h49DFFUieFOfDhE9Tnx5rvXOI,4943
954
+ cirq/testing/consistent_qasm.py,sha256=1-Rq2NfyRHh1bqPYuhBIsH9OkepUSONpNdxDMODSsrQ,5108
955
955
  cirq/testing/consistent_qasm_test.py,sha256=IM1BDeqZflv0Tui669KRLOlKKWyYnJ9JA-Xoy4lI9Bs,2883
956
956
  cirq/testing/consistent_resolve_parameters.py,sha256=hYbp6kbXrOLCc1DMDRC2zTAx1qlvCCJMuzZ7a5cGhmA,1973
957
957
  cirq/testing/consistent_specified_has_unitary.py,sha256=A8UWU8etwXmEs9GWLI94NiIkGUHUHxMNY-5Brqd9oj4,1132
@@ -1152,8 +1152,8 @@ cirq/work/sampler.py,sha256=JEAeQQRF3bqlO9AkOf4XbrTATDI5f5JgyM_FAUCNxao,19751
1152
1152
  cirq/work/sampler_test.py,sha256=B2ZsuqGT854gQtBIAh8k0LiG9Vj5wSzcGvkxOUoTcW4,13217
1153
1153
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1154
1154
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1155
- cirq_core-1.4.0.dev20240228192904.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1156
- cirq_core-1.4.0.dev20240228192904.dist-info/METADATA,sha256=8YwmbxSowVCVOeNL6k_aWDiAxuSq0hyeNd3x18Af39w,2110
1157
- cirq_core-1.4.0.dev20240228192904.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1158
- cirq_core-1.4.0.dev20240228192904.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1159
- cirq_core-1.4.0.dev20240228192904.dist-info/RECORD,,
1155
+ cirq_core-1.4.0.dev20240305032422.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1156
+ cirq_core-1.4.0.dev20240305032422.dist-info/METADATA,sha256=lRVgKFjtZOyzksaKZhORy8dbvbn1YGP1jryPCh7pS4w,2110
1157
+ cirq_core-1.4.0.dev20240305032422.dist-info/WHEEL,sha256=oiQVh_5PnQM0E3gPdiz09WCNmwiHDMaGer_elqB3coM,92
1158
+ cirq_core-1.4.0.dev20240305032422.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1159
+ cirq_core-1.4.0.dev20240305032422.dist-info/RECORD,,