cirq-core 1.5.0.dev20241202173736__py3-none-any.whl → 1.5.0.dev20241202223923__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.dev20241202173736"
31
+ __version__ = "1.5.0.dev20241202223923"
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.dev20241202173736"
6
+ assert cirq.__version__ == "1.5.0.dev20241202223923"
@@ -32,6 +32,7 @@ class QasmLexer:
32
32
  'bit': 'BIT',
33
33
  'creg': 'CREG',
34
34
  'measure': 'MEASURE',
35
+ 'reset': 'RESET',
35
36
  'if': 'IF',
36
37
  '->': 'ARROW',
37
38
  '==': 'EQ',
@@ -115,6 +116,10 @@ class QasmLexer:
115
116
  r"""measure"""
116
117
  return t
117
118
 
119
+ def t_RESET(self, t):
120
+ r"""reset"""
121
+ return t
122
+
118
123
  def t_IF(self, t):
119
124
  r"""if"""
120
125
  return t
@@ -300,6 +300,7 @@ class QasmParser:
300
300
  # circuit : new_reg circuit
301
301
  # | gate_op circuit
302
302
  # | measurement circuit
303
+ # | reset circuit
303
304
  # | if circuit
304
305
  # | empty
305
306
 
@@ -310,6 +311,7 @@ class QasmParser:
310
311
  def p_circuit_gate_or_measurement_or_if(self, p):
311
312
  """circuit : circuit gate_op
312
313
  | circuit measurement
314
+ | circuit reset
313
315
  | circuit if"""
314
316
  self.circuit.append(p[2])
315
317
  p[0] = self.circuit
@@ -526,6 +528,15 @@ class QasmParser:
526
528
  ops.MeasurementGate(num_qubits=1, key=creg[i]).on(qreg[i]) for i in range(len(qreg))
527
529
  ]
528
530
 
531
+ # reset operations
532
+ # reset : RESET qarg
533
+
534
+ def p_reset(self, p):
535
+ """reset : RESET qarg ';'"""
536
+ qreg = p[2]
537
+
538
+ p[0] = [ops.ResetChannel().on(qreg[i]) for i in range(len(qreg))]
539
+
529
540
  # if operations
530
541
  # if : IF '(' carg EQ NATURAL_NUMBER ')' ID qargs
531
542
 
@@ -12,6 +12,7 @@
12
12
  # See the License for the specific language governing permissions and
13
13
  # limitations under the License.
14
14
 
15
+ import textwrap
15
16
  from typing import Callable
16
17
 
17
18
  import numpy as np
@@ -706,6 +707,35 @@ def test_measurement_bounds():
706
707
  parser.parse(qasm)
707
708
 
708
709
 
710
+ def test_reset():
711
+ qasm = textwrap.dedent(
712
+ """\
713
+ OPENQASM 2.0;
714
+ include "qelib1.inc";
715
+ qreg q[1];
716
+ creg c[1];
717
+ x q[0];
718
+ reset q[0];
719
+ measure q[0] -> c[0];
720
+ """
721
+ )
722
+
723
+ parser = QasmParser()
724
+
725
+ q_0 = cirq.NamedQubit('q_0')
726
+
727
+ expected_circuit = Circuit([cirq.X(q_0), cirq.reset(q_0), cirq.measure(q_0, key='c_0')])
728
+
729
+ parsed_qasm = parser.parse(qasm)
730
+
731
+ assert parsed_qasm.supportedFormat
732
+ assert parsed_qasm.qelib1Include
733
+
734
+ ct.assert_same_circuits(parsed_qasm.circuit, expected_circuit)
735
+ assert parsed_qasm.qregs == {'q': 1}
736
+ assert parsed_qasm.cregs == {'c': 1}
737
+
738
+
709
739
  def test_u1_gate():
710
740
  qasm = """
711
741
  OPENQASM 2.0;
@@ -1068,12 +1098,13 @@ def test_openqasm_3_0_qubits():
1068
1098
  x q[0];
1069
1099
 
1070
1100
  b[0] = measure q[0];
1101
+ reset q[0];
1071
1102
  """
1072
1103
  parser = QasmParser()
1073
1104
 
1074
1105
  q0 = cirq.NamedQubit('q_0')
1075
1106
 
1076
- expected_circuit = Circuit([cirq.X.on(q0), cirq.measure(q0, key='b_0')])
1107
+ expected_circuit = Circuit([cirq.X.on(q0), cirq.measure(q0, key='b_0'), cirq.reset(q0)])
1077
1108
 
1078
1109
  parsed_qasm = parser.parse(qasm)
1079
1110
 
@@ -1092,12 +1123,13 @@ def test_openqasm_3_0_scalar_qubit():
1092
1123
  x q;
1093
1124
 
1094
1125
  b = measure q;
1126
+ reset q;
1095
1127
  """
1096
1128
  parser = QasmParser()
1097
1129
 
1098
1130
  q0 = cirq.NamedQubit('q_0')
1099
1131
 
1100
- expected_circuit = Circuit([cirq.X.on(q0), cirq.measure(q0, key='b_0')])
1132
+ expected_circuit = Circuit([cirq.X.on(q0), cirq.measure(q0, key='b_0'), cirq.reset(q0)])
1101
1133
 
1102
1134
  parsed_qasm = parser.parse(qasm)
1103
1135
 
cirq/work/sampler.py CHANGED
@@ -236,13 +236,13 @@ class Sampler(metaclass=value.ABCMetaImplementAnyOneOf):
236
236
  """
237
237
  raise NotImplementedError
238
238
 
239
- def run_batch(
239
+ async def run_batch_async(
240
240
  self,
241
241
  programs: Sequence['cirq.AbstractCircuit'],
242
242
  params_list: Optional[Sequence['cirq.Sweepable']] = None,
243
243
  repetitions: Union[int, Sequence[int]] = 1,
244
244
  ) -> Sequence[Sequence['cirq.Result']]:
245
- """Runs the supplied circuits.
245
+ """Runs the supplied circuits asynchronously.
246
246
 
247
247
  Each circuit provided in `programs` will pair with the optional
248
248
  associated parameter sweep provided in the `params_list`, and be run
@@ -281,26 +281,12 @@ class Sampler(metaclass=value.ABCMetaImplementAnyOneOf):
281
281
  of `params_list` or the length of `repetitions`.
282
282
  """
283
283
  params_list, repetitions = self._normalize_batch_args(programs, params_list, repetitions)
284
- return [
285
- self.run_sweep(circuit, params=params, repetitions=repetitions)
286
- for circuit, params, repetitions in zip(programs, params_list, repetitions)
287
- ]
288
-
289
- async def run_batch_async(
290
- self,
291
- programs: Sequence['cirq.AbstractCircuit'],
292
- params_list: Optional[Sequence['cirq.Sweepable']] = None,
293
- repetitions: Union[int, Sequence[int]] = 1,
294
- ) -> Sequence[Sequence['cirq.Result']]:
295
- """Runs the supplied circuits asynchronously.
296
-
297
- See docs for `cirq.Sampler.run_batch`.
298
- """
299
- params_list, repetitions = self._normalize_batch_args(programs, params_list, repetitions)
300
284
  return await duet.pstarmap_async(
301
285
  self.run_sweep_async, zip(programs, params_list, repetitions)
302
286
  )
303
287
 
288
+ run_batch = duet.sync(run_batch_async)
289
+
304
290
  def _normalize_batch_args(
305
291
  self,
306
292
  programs: Sequence['cirq.AbstractCircuit'],
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: cirq-core
3
- Version: 1.5.0.dev20241202173736
3
+ Version: 1.5.0.dev20241202223923
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=D6ynQI7ZeYrM6zXi6qSIFLkR_6N_rGTA-f61a98H3fw,1206
8
- cirq/_version_test.py,sha256=Sr-dEUA2hgJJeoRDnfwRTiJ499KTmE_PU86Nl6_tLgo,147
7
+ cirq/_version.py,sha256=GRSBxOZ8plN14G9UhoD3b5ec7Uyf_qjCd0DSJdAIMf0,1206
8
+ cirq/_version_test.py,sha256=mNwUXLqOL-RrDZmWrDug4E1rQj8OTkQOac37pIkYijU,147
9
9
  cirq/conftest.py,sha256=X7yLFL8GLhg2CjPw0hp5e_dGASfvHx1-QT03aUbhKJw,1168
10
10
  cirq/json_resolver_cache.py,sha256=ytePZtNZgKjOF2NiVpUTuotB-JKZmQNOFIFdvXqsxHw,13271
11
11
  cirq/py.typed,sha256=VFSlmh_lNwnaXzwY-ZuW-C2Ws5PkuDoVgBdNCs0jXJE,63
@@ -103,10 +103,10 @@ cirq/contrib/paulistring/recombine_test.py,sha256=hJ083nR67JsIs38TfmCjmBLnhqyG0r
103
103
  cirq/contrib/paulistring/separate.py,sha256=2g4l78mXYJDR6xkv51VExZDb-rm5JEvhYrpMPgWa0Us,3961
104
104
  cirq/contrib/paulistring/separate_test.py,sha256=FzR78MSHDhNJxizbXreK6u3BeYhT7xn7W1QyHfEZ34E,1267
105
105
  cirq/contrib/qasm_import/__init__.py,sha256=RKX0vGDC2Pe5rH5rM4ClXdvtrAU16ePFImQpiJtJVNo,744
106
- cirq/contrib/qasm_import/_lexer.py,sha256=1BGtCS2RetdiYPNOe_ZnMeoEl-AVBvvee_7y-h8tYcE,3275
106
+ cirq/contrib/qasm_import/_lexer.py,sha256=J0ExK_6VGMoql0ha0hrxHzbFuqFYazHSSruhgznI66Y,3366
107
107
  cirq/contrib/qasm_import/_lexer_test.py,sha256=iiz-cmIt5hnhHBc4ub4btqHnbi4EPaO7BE7bsJKPet8,4142
108
- cirq/contrib/qasm_import/_parser.py,sha256=e9ztG69dYm8dewM6efizbMT-Mf1n88hffg4ToBu0pig,20153
109
- cirq/contrib/qasm_import/_parser_test.py,sha256=2XEfhoiHWDpnGh3yYrenekGTIYapDtf52AMzYulajRY,28374
108
+ cirq/contrib/qasm_import/_parser.py,sha256=3hTbb7ZzEIS8OoGPo2efemzDQT_dTUS9Yjxt3IP6A4s,20416
109
+ cirq/contrib/qasm_import/_parser_test.py,sha256=XwQ6KrrKCgQwXK4u6-I3suFWGdtScNZdTdQT_ykCcuQ,29108
110
110
  cirq/contrib/qasm_import/exception.py,sha256=Wm6cwUPIkNMPjkv-ELpQ-zSoXaiLOddOQ4iYybwuS6I,695
111
111
  cirq/contrib/qasm_import/qasm.py,sha256=CP444IWCw4zlDNA7HxsTJ2xIak4mZhQv62ZiLlUc2zo,914
112
112
  cirq/contrib/qasm_import/qasm_test.py,sha256=e5b7LVn_6FIFZ6kINqMzJFIjzgtTgutVhgXgX_DcTc0,1861
@@ -1183,12 +1183,12 @@ cirq/work/observable_settings.py,sha256=OsZS8XvHT2LCFGkzu-wh1WShOx93I1nZ2K7uce-i
1183
1183
  cirq/work/observable_settings_test.py,sha256=hV3g5ld5OZchTjVMVL_8cLXsbSBMz5DAsE4Vui2xTuk,4233
1184
1184
  cirq/work/pauli_sum_collector.py,sha256=N1IsIwudBi84XWP1x7LNE2uQ6DGR2LFIWPhGbdHxaA4,4230
1185
1185
  cirq/work/pauli_sum_collector_test.py,sha256=aeo06iLIYZjWjN3C4loVHRYWpV35lSSlcX2cOVdt2Ss,2437
1186
- cirq/work/sampler.py,sha256=y6qtCpAwO8SqZ_JKU8PwlbMLHpJskNPqGWD_pNbyZew,19779
1186
+ cirq/work/sampler.py,sha256=bE5tmVkcR6cZZMLETxDfHehdsYUMbx2RvBeIBetehI4,19187
1187
1187
  cirq/work/sampler_test.py,sha256=hL2UWx3dz2ukZVNxWftiKVvJcQoLplLZdQm-k1QcA40,13282
1188
1188
  cirq/work/zeros_sampler.py,sha256=x1C7cup66a43n-3tm8QjhiqJa07qcJW10FxNp9jJ59Q,2356
1189
1189
  cirq/work/zeros_sampler_test.py,sha256=JIkpBBFPJe5Ba4142vzogyWyboG1Q1ZAm0UVGgOoZn8,3279
1190
- cirq_core-1.5.0.dev20241202173736.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1191
- cirq_core-1.5.0.dev20241202173736.dist-info/METADATA,sha256=BE-y8tWJvMo_4Yld-zhiah3vLNiyVNm9YG_RpQb4VBk,1992
1192
- cirq_core-1.5.0.dev20241202173736.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1193
- cirq_core-1.5.0.dev20241202173736.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1194
- cirq_core-1.5.0.dev20241202173736.dist-info/RECORD,,
1190
+ cirq_core-1.5.0.dev20241202223923.dist-info/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
1191
+ cirq_core-1.5.0.dev20241202223923.dist-info/METADATA,sha256=gv2aCcaGmicJHU22kVosk8D2kglj9k28q02zAerl3sw,1992
1192
+ cirq_core-1.5.0.dev20241202223923.dist-info/WHEEL,sha256=tZoeGjtWxWRfdplE7E3d45VPlLNQnvbKiYnx7gwAy8A,92
1193
+ cirq_core-1.5.0.dev20241202223923.dist-info/top_level.txt,sha256=Sz9iOxHU0IEMLSFGwiwOCaN2e9K-jFbBbtpPN1hB73g,5
1194
+ cirq_core-1.5.0.dev20241202223923.dist-info/RECORD,,