cirq-aqt 1.6.0.dev20250515174529__py3-none-any.whl → 1.7.0.dev20251211190616__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.
cirq_aqt/_version.py CHANGED
@@ -14,4 +14,4 @@
14
14
 
15
15
  """Define version number here, read it from setup.py automatically"""
16
16
 
17
- __version__ = "1.6.0.dev20250515174529"
17
+ __version__ = "1.7.0.dev20251211190616"
cirq_aqt/_version_test.py CHANGED
@@ -3,4 +3,4 @@ import cirq_aqt
3
3
 
4
4
 
5
5
  def test_version():
6
- assert cirq_aqt.__version__ == "1.6.0.dev20250515174529"
6
+ assert cirq_aqt.__version__ == "1.7.0.dev20251211190616"
cirq_aqt/aqt_device.py CHANGED
@@ -24,9 +24,12 @@ arbitrary connectivity. For more information see:
24
24
  The native gate set consists of the local gates: X, Y, and XX entangling gates
25
25
  """
26
26
 
27
+ from __future__ import annotations
28
+
27
29
  import json
30
+ from collections.abc import Iterable, Sequence
28
31
  from enum import Enum
29
- from typing import Any, cast, Dict, Iterable, List, Optional, Sequence, Set, Tuple, Union
32
+ from typing import Any, cast
30
33
 
31
34
  import networkx as nx
32
35
  import numpy as np
@@ -87,7 +90,7 @@ class AQTNoiseModel(cirq.NoiseModel):
87
90
 
88
91
  def noisy_moment(
89
92
  self, moment: cirq.Moment, system_qubits: Sequence[cirq.Qid]
90
- ) -> List[cirq.Operation]:
93
+ ) -> list[cirq.Operation]:
91
94
  """Returns a list of noisy moments.
92
95
 
93
96
  The model includes
@@ -115,7 +118,7 @@ class AQTNoiseModel(cirq.NoiseModel):
115
118
 
116
119
  def get_crosstalk_operation(
117
120
  self, operation: cirq.Operation, system_qubits: Sequence[cirq.Qid]
118
- ) -> List[cirq.Operation]:
121
+ ) -> list[cirq.Operation]:
119
122
  """Returns a list of operations including crosstalk
120
123
 
121
124
  Args:
@@ -125,7 +128,7 @@ class AQTNoiseModel(cirq.NoiseModel):
125
128
  Returns:
126
129
  List of operations including crosstalk
127
130
  """
128
- cast(Tuple[cirq.LineQubit], system_qubits)
131
+ cast(tuple[cirq.LineQubit], system_qubits)
129
132
  num_qubits = len(system_qubits)
130
133
  xtlk_arr = np.zeros(num_qubits)
131
134
  idx_list = []
@@ -167,7 +170,7 @@ class AQTSimulator:
167
170
  num_qubits: int,
168
171
  circuit: cirq.Circuit = cirq.Circuit(),
169
172
  simulate_ideal: bool = False,
170
- noise_dict: Optional[Dict] = None,
173
+ noise_dict: dict | None = None,
171
174
  ):
172
175
  """Initializes the AQT simulator.
173
176
 
@@ -187,7 +190,7 @@ class AQTSimulator:
187
190
  self.noise_dict = noise_dict
188
191
  self.simulate_ideal = simulate_ideal
189
192
 
190
- def generate_circuit_from_list(self, json_string: str):
193
+ def generate_circuit_from_list(self, json_string: str) -> None:
191
194
  """Generates a list of cirq operations from a json string.
192
195
 
193
196
  The default behavior is to add a measurement to any qubit at the end
@@ -198,7 +201,7 @@ class AQTSimulator:
198
201
  """
199
202
  self.circuit = cirq.Circuit()
200
203
  json_obj = json.loads(json_string)
201
- gate: Union[cirq.PhasedXPowGate, cirq.EigenGate]
204
+ gate: cirq.PhasedXPowGate | cirq.EigenGate
202
205
  for circuit_list in json_obj:
203
206
  op_str = circuit_list[0]
204
207
  if op_str == 'R':
@@ -286,11 +289,11 @@ class AQTDevice(cirq.Device):
286
289
  def metadata(self) -> aqt_device_metadata.AQTDeviceMetadata:
287
290
  return self._metadata
288
291
 
289
- def validate_gate(self, gate: cirq.Gate):
292
+ def validate_gate(self, gate: cirq.Gate) -> None:
290
293
  if gate not in self.metadata.gateset:
291
294
  raise ValueError(f'Unsupported gate type: {gate!r}')
292
295
 
293
- def validate_operation(self, operation):
296
+ def validate_operation(self, operation) -> None:
294
297
  if not isinstance(operation, cirq.GateOperation):
295
298
  raise ValueError(f'Unsupported operation: {operation!r}')
296
299
 
@@ -302,11 +305,11 @@ class AQTDevice(cirq.Device):
302
305
  if q not in self.qubits:
303
306
  raise ValueError(f'Qubit not on device: {q!r}')
304
307
 
305
- def validate_circuit(self, circuit: cirq.AbstractCircuit):
308
+ def validate_circuit(self, circuit: cirq.AbstractCircuit) -> None:
306
309
  super().validate_circuit(circuit)
307
310
  _verify_unique_measurement_keys(circuit.all_operations())
308
311
 
309
- def at(self, position: int) -> Optional[cirq.LineQubit]:
312
+ def at(self, position: int) -> cirq.LineQubit | None:
310
313
  """Returns the qubit at the given position, if there is one, else None."""
311
314
  q = cirq.LineQubit(position)
312
315
  return q if q in self.qubits else None
@@ -339,7 +342,7 @@ class AQTDevice(cirq.Device):
339
342
  p.text("AQTDevice(...)" if cycle else self.__str__())
340
343
 
341
344
 
342
- def get_aqt_device(num_qubits: int) -> Tuple[AQTDevice, List[cirq.LineQubit]]:
345
+ def get_aqt_device(num_qubits: int) -> tuple[AQTDevice, list[cirq.LineQubit]]:
343
346
  """Returns an AQT ion device
344
347
 
345
348
  Args:
@@ -359,7 +362,7 @@ def get_aqt_device(num_qubits: int) -> Tuple[AQTDevice, List[cirq.LineQubit]]:
359
362
  return ion_device, qubit_list
360
363
 
361
364
 
362
- def get_default_noise_dict() -> Dict[str, Any]:
365
+ def get_default_noise_dict() -> dict[str, Any]:
363
366
  """Returns the current noise parameters"""
364
367
  default_noise_dict = {
365
368
  OperationString.R.value: cirq.depolarize(1e-3),
@@ -371,7 +374,7 @@ def get_default_noise_dict() -> Dict[str, Any]:
371
374
 
372
375
 
373
376
  def _verify_unique_measurement_keys(operations: Iterable[cirq.Operation]):
374
- seen: Set[str] = set()
377
+ seen: set[str] = set()
375
378
  for op in operations:
376
379
  if isinstance(op.gate, cirq.MeasurementGate):
377
380
  meas = op.gate
@@ -14,7 +14,10 @@
14
14
 
15
15
  """DeviceMetadata for ion trap device with mutually linked qubits placed on a line."""
16
16
 
17
- from typing import Any, Iterable, Mapping
17
+ from __future__ import annotations
18
+
19
+ from collections.abc import Iterable, Mapping
20
+ from typing import Any
18
21
 
19
22
  import networkx as nx
20
23
 
@@ -54,9 +57,9 @@ class AQTDeviceMetadata(cirq.DeviceMetadata):
54
57
  cirq.GateFamily(cirq.ZPowGate): self._oneq_gates_duration,
55
58
  cirq.GateFamily(cirq.PhasedXPowGate): self._oneq_gates_duration,
56
59
  }
57
- assert not self._gateset.gates.symmetric_difference(self._gate_durations.keys()), (
58
- "AQTDeviceMetadata.gate_durations must have the same Gates " "as AQTTargetGateset."
59
- )
60
+ assert not self._gateset.gates.symmetric_difference(
61
+ self._gate_durations.keys()
62
+ ), "AQTDeviceMetadata.gate_durations must have the same Gates as AQTTargetGateset."
60
63
 
61
64
  @property
62
65
  def gateset(self) -> cirq.Gateset:
@@ -14,7 +14,7 @@
14
14
 
15
15
  """Tests for AQTDeviceMetadata."""
16
16
 
17
- from typing import List
17
+ from __future__ import annotations
18
18
 
19
19
  import pytest
20
20
 
@@ -24,7 +24,7 @@ from cirq_aqt.aqt_target_gateset import AQTTargetGateset
24
24
 
25
25
 
26
26
  @pytest.fixture
27
- def qubits() -> List[cirq.LineQubit]:
27
+ def qubits() -> list[cirq.LineQubit]:
28
28
  return cirq.LineQubit.range(5)
29
29
 
30
30
 
@@ -38,7 +38,7 @@ def metadata(qubits) -> AQTDeviceMetadata:
38
38
  )
39
39
 
40
40
 
41
- def test_aqtdevice_metadata(metadata, qubits):
41
+ def test_aqtdevice_metadata(metadata, qubits) -> None:
42
42
  assert metadata.qubit_set == frozenset(qubits)
43
43
  assert set(qubits) == set(metadata.nx_graph.nodes())
44
44
  edges = metadata.nx_graph.edges()
@@ -48,7 +48,7 @@ def test_aqtdevice_metadata(metadata, qubits):
48
48
  assert len(metadata.gate_durations) == 4
49
49
 
50
50
 
51
- def test_aqtdevice_duration_of(metadata, qubits):
51
+ def test_aqtdevice_duration_of(metadata, qubits) -> None:
52
52
  q0, q1 = qubits[:2]
53
53
  ms = cirq.Duration(millis=1)
54
54
  assert metadata.duration_of(cirq.Z(q0)) == 10 * ms
@@ -59,5 +59,5 @@ def test_aqtdevice_duration_of(metadata, qubits):
59
59
  metadata.duration_of(cirq.I(q0))
60
60
 
61
61
 
62
- def test_repr(metadata):
62
+ def test_repr(metadata) -> None:
63
63
  cirq.testing.assert_equivalent_repr(metadata, setup_code='import cirq\nimport cirq_aqt\n')
@@ -15,7 +15,6 @@
15
15
  from __future__ import annotations
16
16
 
17
17
  from datetime import timedelta
18
- from typing import List
19
18
 
20
19
  import pytest
21
20
 
@@ -24,7 +23,7 @@ from cirq_aqt import aqt_device, aqt_device_metadata
24
23
 
25
24
 
26
25
  @pytest.fixture
27
- def qubits() -> List[cirq.LineQubit]:
26
+ def qubits() -> list[cirq.LineQubit]:
28
27
  return cirq.LineQubit.range(3)
29
28
 
30
29
 
@@ -44,11 +43,11 @@ class NotImplementedOperation(cirq.Operation):
44
43
  raise NotImplementedError()
45
44
 
46
45
  @property
47
- def qubits(self):
46
+ def qubits(self) -> tuple[cirq.Qid, ...]:
48
47
  raise NotImplementedError()
49
48
 
50
49
 
51
- def test_init_qubits(device, qubits):
50
+ def test_init_qubits(device, qubits) -> None:
52
51
  ms = cirq.Duration(millis=1)
53
52
  assert device.qubits == frozenset(qubits)
54
53
  with pytest.raises(TypeError, match="NamedQubit"):
@@ -56,12 +55,12 @@ def test_init_qubits(device, qubits):
56
55
  measurement_duration=100 * ms,
57
56
  twoq_gates_duration=200 * ms,
58
57
  oneq_gates_duration=10 * ms,
59
- qubits=[cirq.LineQubit(0), cirq.NamedQubit("a")],
58
+ qubits=[cirq.LineQubit(0), cirq.NamedQubit("a")], # type: ignore[list-item]
60
59
  )
61
60
 
62
61
 
63
62
  @pytest.mark.parametrize('ms', [cirq.Duration(millis=1), timedelta(milliseconds=1)])
64
- def test_init_durations(ms, qubits):
63
+ def test_init_durations(ms, qubits) -> None:
65
64
  dev = aqt_device.AQTDevice(
66
65
  qubits=qubits,
67
66
  measurement_duration=100 * ms,
@@ -73,12 +72,12 @@ def test_init_durations(ms, qubits):
73
72
  assert dev.metadata.measurement_duration == cirq.Duration(millis=100)
74
73
 
75
74
 
76
- def test_metadata(device, qubits):
75
+ def test_metadata(device, qubits) -> None:
77
76
  assert isinstance(device.metadata, aqt_device_metadata.AQTDeviceMetadata)
78
77
  assert device.metadata.qubit_set == frozenset(qubits)
79
78
 
80
79
 
81
- def test_repr(device):
80
+ def test_repr(device) -> None:
82
81
  assert repr(device) == (
83
82
  "cirq_aqt.aqt_device.AQTDevice("
84
83
  "measurement_duration=cirq.Duration(millis=100), "
@@ -90,13 +89,13 @@ def test_repr(device):
90
89
  cirq.testing.assert_equivalent_repr(device, setup_code='import cirq\nimport cirq_aqt\n')
91
90
 
92
91
 
93
- def test_validate_measurement_non_adjacent_qubits_ok(device):
92
+ def test_validate_measurement_non_adjacent_qubits_ok(device) -> None:
94
93
  device.validate_operation(
95
94
  cirq.GateOperation(cirq.MeasurementGate(2, 'key'), (cirq.LineQubit(0), cirq.LineQubit(1)))
96
95
  )
97
96
 
98
97
 
99
- def test_validate_operation_existing_qubits(device):
98
+ def test_validate_operation_existing_qubits(device) -> None:
100
99
  device.validate_operation(cirq.GateOperation(cirq.XX, (cirq.LineQubit(0), cirq.LineQubit(1))))
101
100
  device.validate_operation(cirq.Z(cirq.LineQubit(0)))
102
101
  device.validate_operation(
@@ -115,7 +114,7 @@ def test_validate_operation_existing_qubits(device):
115
114
  device.validate_operation(cirq.X(cirq.NamedQubit("q1")))
116
115
 
117
116
 
118
- def test_validate_operation_supported_gate(device):
117
+ def test_validate_operation_supported_gate(device) -> None:
119
118
  class MyGate(cirq.Gate):
120
119
  def num_qubits(self):
121
120
  return 1
@@ -129,12 +128,12 @@ def test_validate_operation_supported_gate(device):
129
128
  device.validate_operation(NotImplementedOperation())
130
129
 
131
130
 
132
- def test_aqt_device_eq(device):
131
+ def test_aqt_device_eq(device) -> None:
133
132
  eq = cirq.testing.EqualsTester()
134
133
  eq.make_equality_group(lambda: device)
135
134
 
136
135
 
137
- def test_validate_circuit_repeat_measurement_keys(device):
136
+ def test_validate_circuit_repeat_measurement_keys(device) -> None:
138
137
  circuit = cirq.Circuit()
139
138
  circuit.append(
140
139
  [cirq.measure(cirq.LineQubit(0), key='a'), cirq.measure(cirq.LineQubit(1), key='a')]
@@ -144,16 +143,16 @@ def test_validate_circuit_repeat_measurement_keys(device):
144
143
  device.validate_circuit(circuit)
145
144
 
146
145
 
147
- def test_aqt_device_str(device):
146
+ def test_aqt_device_str(device) -> None:
148
147
  assert str(device) == "q(0)───q(1)───q(2)"
149
148
 
150
149
 
151
- def test_aqt_device_pretty_repr(device):
150
+ def test_aqt_device_pretty_repr(device) -> None:
152
151
  cirq.testing.assert_repr_pretty(device, "q(0)───q(1)───q(2)")
153
152
  cirq.testing.assert_repr_pretty(device, "AQTDevice(...)", cycle=True)
154
153
 
155
154
 
156
- def test_at(device):
155
+ def test_at(device) -> None:
157
156
  assert device.at(-1) is None
158
157
  assert device.at(0) == cirq.LineQubit(0)
159
158
  assert device.at(2) == cirq.LineQubit(2)
cirq_aqt/aqt_sampler.py CHANGED
@@ -22,10 +22,13 @@ API keys for classical simulators and quantum devices can be obtained at:
22
22
 
23
23
  """
24
24
 
25
+ from __future__ import annotations
26
+
25
27
  import json
26
28
  import time
27
29
  import uuid
28
- from typing import Callable, cast, Dict, List, Literal, Sequence, Tuple, TypedDict, Union
30
+ from collections.abc import Callable, Sequence
31
+ from typing import cast, Literal, TypedDict
29
32
  from urllib.parse import urljoin
30
33
 
31
34
  import numpy as np
@@ -249,16 +252,14 @@ class AQTSampler(cirq.Sampler):
249
252
  RuntimeError: If the circuit is empty.
250
253
  """
251
254
 
252
- seq_list: List[Union[Tuple[str, float, List[int]], Tuple[str, float, float, List[int]]]] = (
253
- []
254
- )
255
+ seq_list: list[tuple[str, float, list[int]] | tuple[str, float, float, list[int]]] = []
255
256
  circuit = cirq.resolve_parameters(circuit, param_resolver)
256
257
  for op in circuit.all_operations():
257
- line_qubit = cast(Tuple[cirq.LineQubit], op.qubits)
258
+ line_qubit = cast(tuple[cirq.LineQubit], op.qubits)
258
259
  op = cast(cirq.GateOperation, op)
259
260
  qubit_idx = [obj.x for obj in line_qubit]
260
261
  op_str = get_op_string(op)
261
- gate: Union[cirq.EigenGate, cirq.PhasedXPowGate]
262
+ gate: cirq.EigenGate | cirq.PhasedXPowGate
262
263
  if op_str == 'R':
263
264
  gate = cast(cirq.PhasedXPowGate, op.gate)
264
265
  seq_list.append(
@@ -367,7 +368,7 @@ class AQTSampler(cirq.Sampler):
367
368
 
368
369
  response = post(submission_url, json=submission_data, headers=headers)
369
370
  response = response.json()
370
- data = cast(Dict, response)
371
+ data = cast(dict, response)
371
372
 
372
373
  if 'response' not in data.keys() or 'status' not in data['response'].keys():
373
374
  raise RuntimeError('Got unexpected return data from server: \n' + str(data))
@@ -382,7 +383,7 @@ class AQTSampler(cirq.Sampler):
382
383
  while True:
383
384
  response = get(result_url, headers=headers)
384
385
  response = response.json()
385
- data = cast(Dict, response)
386
+ data = cast(dict, response)
386
387
 
387
388
  if 'response' not in data.keys() or 'status' not in data['response'].keys():
388
389
  raise RuntimeError('Got unexpected return data from AQT server: \n' + str(data))
@@ -424,7 +425,7 @@ class AQTSampler(cirq.Sampler):
424
425
  # TODO: Use measurement name from circuit.
425
426
  # Github issue: https://github.com/quantumlib/Cirq/issues/2199
426
427
  meas_name = 'm'
427
- trial_results: List[cirq.Result] = []
428
+ trial_results: list[cirq.Result] = []
428
429
  for param_resolver in cirq.to_resolvers(params):
429
430
  id_str = str(uuid.uuid1())
430
431
  num_qubits = len(program.all_qubits())
@@ -12,7 +12,10 @@
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 json
18
+ from typing import Any, Self
16
19
  from unittest import mock
17
20
 
18
21
  import numpy as np
@@ -31,11 +34,11 @@ class GetResultReturn:
31
34
  self.test_dict = {'job': {'job_id': '2131da'}, 'response': {'status': 'queued'}}
32
35
  self.counter = 0
33
36
 
34
- def json(self):
37
+ def json(self) -> dict[str, Any]:
35
38
  self.counter += 1
36
39
  return self.test_dict
37
40
 
38
- def update(self, *args, **kwargs):
41
+ def update(self, *args, **kwargs) -> Self:
39
42
  return self
40
43
 
41
44
 
@@ -53,7 +56,7 @@ class GetResultNoStatus(GetResultReturn):
53
56
  """A put mock class for testing error responses
54
57
  This will not return a status in the second call"""
55
58
 
56
- def update(self, *args, **kwargs):
59
+ def update(self, *args, **kwargs) -> Self:
57
60
  del self.test_dict['response']['status']
58
61
  return self
59
62
 
@@ -62,14 +65,14 @@ class GetResultErrorSecond(GetResultReturn):
62
65
  """A put mock class for testing error responses
63
66
  This will return an error on the second put call"""
64
67
 
65
- def update(self, *args, **kwargs):
68
+ def update(self, *args, **kwargs) -> Self:
66
69
  if self.counter >= 1:
67
70
  self.test_dict['response']['status'] = 'error'
68
71
  return self
69
72
 
70
73
 
71
74
  class SubmitGoodResponse:
72
- def json(self):
75
+ def json(self) -> dict[str, Any]:
73
76
  return {"job": {"job_id": "test_job"}, "response": {"status": "queued"}}
74
77
 
75
78
 
@@ -77,7 +80,7 @@ class SubmitResultNoID:
77
80
  """A put mock class for testing error responses
78
81
  This will not return an id at the first call"""
79
82
 
80
- def json(self):
83
+ def json(self) -> dict[str, Any]:
81
84
  return {"job": {}, "response": {"status": "queued"}}
82
85
 
83
86
 
@@ -85,7 +88,7 @@ class SubmitResultNoStatus:
85
88
  """A put mock class for testing error responses
86
89
  This will not return an id at the first call"""
87
90
 
88
- def json(self):
91
+ def json(self) -> dict[str, Any]:
89
92
  return {"job": {"job_id": "test_job"}, "response": {}}
90
93
 
91
94
 
@@ -93,11 +96,11 @@ class SubmitResultWithError:
93
96
  """A put mock class for testing error responses
94
97
  This will not return an id at the first call"""
95
98
 
96
- def json(self):
99
+ def json(self) -> dict[str, Any]:
97
100
  return {"job": {"job_id": "test_job"}, "response": {"status": "error"}}
98
101
 
99
102
 
100
- def test_aqt_sampler_submit_job_error_handling():
103
+ def test_aqt_sampler_submit_job_error_handling() -> None:
101
104
  for e_return in [SubmitResultNoID(), SubmitResultNoStatus(), SubmitResultWithError()]:
102
105
  with (
103
106
  mock.patch('cirq_aqt.aqt_sampler.post', return_value=e_return),
@@ -117,7 +120,7 @@ def test_aqt_sampler_submit_job_error_handling():
117
120
  _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions)
118
121
 
119
122
 
120
- def test_aqt_sampler_get_result_error_handling():
123
+ def test_aqt_sampler_get_result_error_handling() -> None:
121
124
  for e_return in [GetResultError(), GetResultErrorSecond(), GetResultNoStatus()]:
122
125
  with (
123
126
  mock.patch('cirq_aqt.aqt_sampler.post', return_value=SubmitGoodResponse()),
@@ -139,7 +142,7 @@ def test_aqt_sampler_get_result_error_handling():
139
142
  _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions)
140
143
 
141
144
 
142
- def test_aqt_sampler_empty_circuit():
145
+ def test_aqt_sampler_empty_circuit() -> None:
143
146
  num_points = 10
144
147
  max_angle = np.pi
145
148
  repetitions = 1000
@@ -153,7 +156,7 @@ def test_aqt_sampler_empty_circuit():
153
156
  _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions)
154
157
 
155
158
 
156
- def test_aqt_sampler():
159
+ def test_aqt_sampler() -> None:
157
160
  class ResultReturn:
158
161
  def __init__(self):
159
162
  self.request_counter = 0
@@ -198,7 +201,7 @@ def test_aqt_sampler():
198
201
  assert result_method.call_count == 3
199
202
 
200
203
 
201
- def test_aqt_sampler_sim():
204
+ def test_aqt_sampler_sim() -> None:
202
205
  theta = sympy.Symbol('theta')
203
206
  num_points = 10
204
207
  max_angle = np.pi
@@ -226,7 +229,7 @@ def test_aqt_sampler_sim():
226
229
  assert excited_state_probs[-1] == 0.25
227
230
 
228
231
 
229
- def test_aqt_sampler_sim_xtalk():
232
+ def test_aqt_sampler_sim_xtalk() -> None:
230
233
  num_points = 10
231
234
  max_angle = np.pi
232
235
  repetitions = 100
@@ -247,7 +250,7 @@ def test_aqt_sampler_sim_xtalk():
247
250
  _results = sampler.run_sweep(circuit, params=sweep, repetitions=repetitions)
248
251
 
249
252
 
250
- def test_aqt_sampler_ms():
253
+ def test_aqt_sampler_ms() -> None:
251
254
  repetitions = 1000
252
255
  num_qubits = 4
253
256
  _, qubits = get_aqt_device(num_qubits)
@@ -262,7 +265,7 @@ def test_aqt_sampler_ms():
262
265
  assert hist[0] > repetitions / 3
263
266
 
264
267
 
265
- def test_aqt_device_wrong_op_str():
268
+ def test_aqt_device_wrong_op_str() -> None:
266
269
  circuit = cirq.Circuit()
267
270
  q0, q1 = cirq.LineQubit.range(2)
268
271
  circuit.append(cirq.CNOT(q0, q1) ** 1.0)
@@ -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
 
17
19
  import cirq
@@ -19,13 +21,13 @@ from cirq_aqt import AQTSimulator
19
21
  from cirq_aqt.aqt_device import AQTNoiseModel, get_aqt_device
20
22
 
21
23
 
22
- def test_simulator_no_circ():
24
+ def test_simulator_no_circ() -> None:
23
25
  with pytest.raises(RuntimeError):
24
26
  sim = AQTSimulator(num_qubits=1)
25
27
  sim.simulate_samples(1)
26
28
 
27
29
 
28
- def test_ms_crosstalk_n_noise():
30
+ def test_ms_crosstalk_n_noise() -> None:
29
31
  num_qubits = 4
30
32
  noise_mod = AQTNoiseModel()
31
33
  _, qubits = get_aqt_device(num_qubits)
@@ -14,12 +14,16 @@
14
14
 
15
15
  """Target gateset for ion trap device with mutually linked qubits placed on a line."""
16
16
 
17
- from typing import List
17
+ from __future__ import annotations
18
+
19
+ from typing import TYPE_CHECKING
18
20
 
19
21
  import numpy as np
20
22
 
21
23
  import cirq
22
- from cirq.protocols.decompose_protocol import DecomposeResult
24
+
25
+ if TYPE_CHECKING:
26
+ from cirq.protocols.decompose_protocol import DecomposeResult
23
27
 
24
28
 
25
29
  class AQTTargetGateset(cirq.TwoQubitCompilationTargetGateset):
@@ -65,6 +69,6 @@ class AQTTargetGateset(cirq.TwoQubitCompilationTargetGateset):
65
69
  return NotImplemented
66
70
 
67
71
  @property
68
- def postprocess_transformers(self) -> List[cirq.TRANSFORMER]:
72
+ def postprocess_transformers(self) -> list[cirq.TRANSFORMER]:
69
73
  """List of transformers which should be run after decomposing individual operations."""
70
74
  return [cirq.drop_negligible_operations, cirq.drop_empty_moments]
@@ -14,6 +14,8 @@
14
14
 
15
15
  """Tests for AQTTargetGateset."""
16
16
 
17
+ from __future__ import annotations
18
+
17
19
  import pytest
18
20
  import sympy
19
21
 
@@ -49,24 +51,27 @@ Q, Q2, Q3, Q4 = cirq.LineQubit.range(4)
49
51
  (cirq.ZPowGate(exponent=0.5)(Q).controlled_by(Q2, Q3), False),
50
52
  ],
51
53
  )
52
- def test_gateset(op: cirq.Operation, expected: bool):
54
+ def test_gateset(op: cirq.Operation, expected: bool) -> None:
53
55
  gs = aqt_target_gateset.AQTTargetGateset()
54
56
  assert gs.validate(op) == expected
55
57
  assert gs.validate(cirq.Circuit(op)) == expected
56
58
 
57
59
 
58
- def test_decompose_single_qubit_operation():
60
+ def test_decompose_single_qubit_operation() -> None:
59
61
  gs = aqt_target_gateset.AQTTargetGateset()
60
62
  tgoph = gs.decompose_to_target_gateset(cirq.H(Q), 0)
63
+ assert isinstance(tgoph, list)
61
64
  assert len(tgoph) == 2
62
65
  assert isinstance(tgoph[0].gate, cirq.Rx)
63
66
  assert isinstance(tgoph[1].gate, cirq.Ry)
64
67
  tcoph = cirq.CircuitOperation(cirq.FrozenCircuit(cirq.H(Q))).with_tags('tagged')
65
68
  tgtcoph = gs.decompose_to_target_gateset(tcoph, 0)
69
+ assert isinstance(tgtcoph, list)
66
70
  assert len(tgtcoph) == 2
67
71
  assert isinstance(tgtcoph[0].gate, cirq.Rx)
68
72
  assert isinstance(tgtcoph[1].gate, cirq.Ry)
69
73
  tgopz = gs.decompose_to_target_gateset(cirq.Z(Q), 0)
74
+ assert isinstance(tgopz, list)
70
75
  assert len(tgopz) == 1
71
76
  assert isinstance(tgopz[0].gate, cirq.ZPowGate)
72
77
  theta = sympy.Symbol('theta')
@@ -74,9 +79,10 @@ def test_decompose_single_qubit_operation():
74
79
  return
75
80
 
76
81
 
77
- def test_decompose_two_qubit_operation():
82
+ def test_decompose_two_qubit_operation() -> None:
78
83
  gs = aqt_target_gateset.AQTTargetGateset()
79
84
  tgopsqrtxx = gs.decompose_to_target_gateset(cirq.XX(Q, Q2) ** 0.5, 0)
85
+ assert isinstance(tgopsqrtxx, list)
80
86
  assert len(tgopsqrtxx) == 1
81
87
  assert isinstance(tgopsqrtxx[0].gate, cirq.XXPowGate)
82
88
  theta = sympy.Symbol('theta')
@@ -84,6 +90,6 @@ def test_decompose_two_qubit_operation():
84
90
  return
85
91
 
86
92
 
87
- def test_postprocess_transformers():
93
+ def test_postprocess_transformers() -> None:
88
94
  gs = aqt_target_gateset.AQTTargetGateset()
89
95
  assert len(gs.postprocess_transformers) == 2
cirq_aqt/conftest.py CHANGED
@@ -15,5 +15,5 @@
15
15
  import os
16
16
 
17
17
 
18
- def pytest_configure(config):
18
+ def pytest_configure(config) -> None:
19
19
  os.environ['CIRQ_TESTING'] = "true"
@@ -12,12 +12,15 @@
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 functools
16
- from typing import Dict
18
+ from typing import TYPE_CHECKING
17
19
 
18
- from cirq.protocols.json_serialization import ObjectFactory
20
+ if TYPE_CHECKING:
21
+ from cirq.protocols.json_serialization import ObjectFactory
19
22
 
20
23
 
21
24
  @functools.lru_cache()
22
- def _class_resolver_dictionary() -> Dict[str, ObjectFactory]:
25
+ def _class_resolver_dictionary() -> dict[str, ObjectFactory]:
23
26
  return {}
@@ -1,19 +1,18 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: cirq-aqt
3
- Version: 1.6.0.dev20250515174529
3
+ Version: 1.7.0.dev20251211190616
4
4
  Summary: A Cirq package to simulate and connect to Alpine Quantum Technologies quantum computers
5
5
  Home-page: http://github.com/quantumlib/cirq
6
6
  Author: The Cirq Developers
7
7
  Author-email: cirq-dev@googlegroups.com
8
8
  Maintainer: Google Quantum AI open-source maintainers
9
9
  Maintainer-email: quantum-oss-maintainers@google.com
10
- License: Apache 2
10
+ License: Apache-2.0
11
11
  Keywords: algorithms,api,cirq,google,google quantum,nisq,python,quantum,quantum algorithms,quantum circuit,quantum circuit simulator,quantum computer simulator,quantum computing,quantum development kit,quantum information,quantum programming,quantum programming language,quantum simulation,sdk,simulation
12
12
  Classifier: Development Status :: 5 - Production/Stable
13
13
  Classifier: Intended Audience :: Developers
14
14
  Classifier: Intended Audience :: Education
15
15
  Classifier: Intended Audience :: Science/Research
16
- Classifier: License :: OSI Approved :: Apache Software License
17
16
  Classifier: Operating System :: MacOS :: MacOS X
18
17
  Classifier: Operating System :: Microsoft :: Windows
19
18
  Classifier: Operating System :: POSIX :: Linux
@@ -28,7 +27,7 @@ Requires-Python: >=3.11.0
28
27
  Description-Content-Type: text/markdown
29
28
  License-File: LICENSE
30
29
  Requires-Dist: requests~=2.32
31
- Requires-Dist: cirq-core==1.6.0.dev20250515174529
30
+ Requires-Dist: cirq-core==1.7.0.dev20251211190616
32
31
  Dynamic: author
33
32
  Dynamic: author-email
34
33
  Dynamic: classifier
@@ -0,0 +1,21 @@
1
+ cirq_aqt/__init__.py,sha256=M8r1U_8xYpcIUhs8U110BFWQ4jUCqS9IQf8trjq0rvI,888
2
+ cirq_aqt/_version.py,sha256=fPl9oAdnRZ0GC3NQMzPAdLYNNvrIyk4w8HqeouvsTgw,696
3
+ cirq_aqt/_version_test.py,sha256=m1uzmwu2GhY8PH1nNP7pU1rDkDdZj5rsHK0Qkqd0vsE,155
4
+ cirq_aqt/aqt_device.py,sha256=hu0f8Ct0rkAJvBUgShDawVAUKzXLTHt7nzoT2Yny5cs,13690
5
+ cirq_aqt/aqt_device_metadata.py,sha256=LWPwPvQYPkwietulNqzxeJ9_pEFkFpIKOTi2QMuHkkc,4811
6
+ cirq_aqt/aqt_device_metadata_test.py,sha256=jzKPFEHuHJ_GeKBKCu5eQDQHak4TKFv_GmLIR9Wfm80,2146
7
+ cirq_aqt/aqt_device_test.py,sha256=uu9EWQAOZ8bw0fvlRgFPcmLqJvhu48sLjVBJHOLVrH0,5367
8
+ cirq_aqt/aqt_sampler.py,sha256=WU6lSdw0JrXKaLW9DJZ8i1qWJeUoMhSOSCMANk0OWYE,18379
9
+ cirq_aqt/aqt_sampler_test.py,sha256=2N1-cs1emcSKTQo3qTdHqsddcxKndiII5RSlh8qVhwM,16646
10
+ cirq_aqt/aqt_simulator_test.py,sha256=Kwd8bnQGSA_NTymPedOo8wvy2AZHp2fWyKFW4WFhWQM,1693
11
+ cirq_aqt/aqt_target_gateset.py,sha256=ZxrmxhXwM81OL5HFJ_jrW7TkliN4X4CAJa8dIJxHaz8,2840
12
+ cirq_aqt/aqt_target_gateset_test.py,sha256=Y6xgNE_bMC1934FHQwvjoswm2gQzz6tI2wjV98EG8bo,3550
13
+ cirq_aqt/conftest.py,sha256=sl0zfNCkCC6KnRiH5uWpL8lk9xrnNZsUc8-Kff29dic,675
14
+ cirq_aqt/json_resolver_cache.py,sha256=qGUV-S69bnqqg2UAgnhVbW0ZHC8UczZr8KBmj09KCso,855
15
+ cirq_aqt/json_test_data/__init__.py,sha256=UZKkYSBrgpUKN5Y5Gb-SJzJAa7h-oTA0K3BKecMbDs8,904
16
+ cirq_aqt/json_test_data/spec.py,sha256=OfF8lLmTIVJF9ZgGoKBjx7tqYG5qvkLo6RqK19DtFCA,1050
17
+ cirq_aqt-1.7.0.dev20251211190616.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
18
+ cirq_aqt-1.7.0.dev20251211190616.dist-info/METADATA,sha256=YZ8y__JPEOuRNI95jk48ddS8KwioMmw3ImTnHK60Mts,4717
19
+ cirq_aqt-1.7.0.dev20251211190616.dist-info/WHEEL,sha256=_zCd3N1l69ArxyTb8rzEoP9TpbYXkqRFSNOD5OuxnTs,91
20
+ cirq_aqt-1.7.0.dev20251211190616.dist-info/top_level.txt,sha256=culYyFTEtuC3Z7wT3wZ6kGVspH3hYFZUEKooByfe9h0,9
21
+ cirq_aqt-1.7.0.dev20251211190616.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (80.7.1)
2
+ Generator: setuptools (80.9.0)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5
 
@@ -1,21 +0,0 @@
1
- cirq_aqt/__init__.py,sha256=M8r1U_8xYpcIUhs8U110BFWQ4jUCqS9IQf8trjq0rvI,888
2
- cirq_aqt/_version.py,sha256=M5V1oFJsaJ_0Yt2o2L4wz2WoffZiQlnQJMyNQBaTnUo,696
3
- cirq_aqt/_version_test.py,sha256=DrEs7JU99xCwYHY9WRq7xeU35C1wp0pf6Hn233DO7_0,155
4
- cirq_aqt/aqt_device.py,sha256=kiKhKPSUmebzFRiZrF7cq76ueHCC3SMF2CVrAAc6NfI,13648
5
- cirq_aqt/aqt_device_metadata.py,sha256=2YIDZKJbt0iHdplBkjfDWK9FSbTzp6m_ggJTcFJfphk,4753
6
- cirq_aqt/aqt_device_metadata_test.py,sha256=naTXEU4VCCdR__gBlzbWjR0-DzViZ1xgVrH_GAyjskY,2111
7
- cirq_aqt/aqt_device_test.py,sha256=reeS9xdmamOGICmz6y6tBmKsc0EZFPWVUrpe3Hw53QE,5244
8
- cirq_aqt/aqt_sampler.py,sha256=wBgTenfELWTx1fCMFaTio9WYpxiBiQndWNp8NAEsfMk,18378
9
- cirq_aqt/aqt_sampler_test.py,sha256=cA68zrJTh57Ge8TW6xd4Q__l0wah_VJ4k6BL_SVPnHw,16403
10
- cirq_aqt/aqt_simulator_test.py,sha256=QjqR6cULJdHEdTI4IxFCaJkhPIvR728hYCvg4RLPW-A,1641
11
- cirq_aqt/aqt_target_gateset.py,sha256=-dxZ-dAEAZHtjPjTJ3VpTipXyYLI5m9-9skOCJmmAAE,2772
12
- cirq_aqt/aqt_target_gateset_test.py,sha256=mZuuDvBl-o6l7ShNzcf_BrIc79I00To_RHt3y7hyOHg,3335
13
- cirq_aqt/conftest.py,sha256=2-K0ZniZ28adwVNB-f5IqvYjavKEBwC4jes_WQ17Xzg,667
14
- cirq_aqt/json_resolver_cache.py,sha256=oZUTckLvATBDSrn-Y6kEAjHjiGXtKc-Bz_i23WsxFj8,788
15
- cirq_aqt/json_test_data/__init__.py,sha256=UZKkYSBrgpUKN5Y5Gb-SJzJAa7h-oTA0K3BKecMbDs8,904
16
- cirq_aqt/json_test_data/spec.py,sha256=OfF8lLmTIVJF9ZgGoKBjx7tqYG5qvkLo6RqK19DtFCA,1050
17
- cirq_aqt-1.6.0.dev20250515174529.dist-info/licenses/LICENSE,sha256=tAkwu8-AdEyGxGoSvJ2gVmQdcicWw3j1ZZueVV74M-E,11357
18
- cirq_aqt-1.6.0.dev20250515174529.dist-info/METADATA,sha256=ghvIekA770Hl32HA-hQ-ETV1QLycQUFOruBfqOvyFto,4778
19
- cirq_aqt-1.6.0.dev20250515174529.dist-info/WHEEL,sha256=Nw36Djuh_5VDukK0H78QzOX-_FQEo6V37m3nkm96gtU,91
20
- cirq_aqt-1.6.0.dev20250515174529.dist-info/top_level.txt,sha256=culYyFTEtuC3Z7wT3wZ6kGVspH3hYFZUEKooByfe9h0,9
21
- cirq_aqt-1.6.0.dev20250515174529.dist-info/RECORD,,