Skip to content

Commit 5b580b0

Browse files
committed
Skip magic trailing comma
1 parent 7e9e744 commit 5b580b0

15 files changed

+186
-439
lines changed

Diff for: cirq-google/cirq_google/engine/abstract_local_processor_test.py

+18-63
Original file line numberDiff line numberDiff line change
@@ -91,10 +91,7 @@ def test_datetime():
9191
def test_bad_reservation():
9292
p = NothingProcessor(processor_id='test')
9393
with pytest.raises(ValueError, match='after the start time'):
94-
_ = p.create_reservation(
95-
start_time=_time(2000000),
96-
end_time=_time(1000000),
97-
)
94+
_ = p.create_reservation(start_time=_time(2000000), end_time=_time(1000000))
9895

9996

10097
def test_reservations():
@@ -212,25 +209,13 @@ def test_get_schedule():
212209
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.OPEN_SWIM,
213210
)
214211
p = NothingProcessor(processor_id='test', schedule=[unbounded_start, unbounded_end])
215-
assert p.get_schedule(
216-
from_time=_time(500000),
217-
to_time=_time(2500000),
218-
) == [unbounded_start, unbounded_end]
219-
assert p.get_schedule(
220-
from_time=_time(1500000),
221-
to_time=_time(2500000),
222-
) == [unbounded_end]
223-
assert p.get_schedule(
224-
from_time=_time(500000),
225-
to_time=_time(1500000),
226-
) == [unbounded_start]
227-
assert (
228-
p.get_schedule(
229-
from_time=_time(1200000),
230-
to_time=_time(1500000),
231-
)
232-
== []
233-
)
212+
assert p.get_schedule(from_time=_time(500000), to_time=_time(2500000)) == [
213+
unbounded_start,
214+
unbounded_end,
215+
]
216+
assert p.get_schedule(from_time=_time(1500000), to_time=_time(2500000)) == [unbounded_end]
217+
assert p.get_schedule(from_time=_time(500000), to_time=_time(1500000)) == [unbounded_start]
218+
assert p.get_schedule(from_time=_time(1200000), to_time=_time(1500000)) == []
234219

235220

236221
@pytest.mark.parametrize(
@@ -257,10 +242,7 @@ def test_get_schedule():
257242
def test_create_reservation_not_available(time_slot):
258243
p = NothingProcessor(processor_id='test', schedule=[time_slot])
259244
with pytest.raises(ValueError, match='Time slot is not available for reservations'):
260-
p.create_reservation(
261-
start_time=_time(500000),
262-
end_time=_time(1500000),
263-
)
245+
p.create_reservation(start_time=_time(500000), end_time=_time(1500000))
264246

265247

266248
def test_create_reservation_open_time_slots():
@@ -271,10 +253,7 @@ def test_create_reservation_open_time_slots():
271253
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
272254
)
273255
p = NothingProcessor(processor_id='test', schedule=[time_slot])
274-
p.create_reservation(
275-
start_time=_time(500000),
276-
end_time=_time(1500000),
277-
)
256+
p.create_reservation(start_time=_time(500000), end_time=_time(1500000))
278257
assert p.get_schedule(from_time=_time(200000), to_time=_time(2500000)) == [
279258
quantum.QuantumTimeSlot(
280259
processor_name='test',
@@ -299,10 +278,7 @@ def test_create_reservation_split_time_slots():
299278
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
300279
)
301280
p = NothingProcessor(processor_id='test', schedule=[time_slot])
302-
p.create_reservation(
303-
start_time=_time(1200000),
304-
end_time=_time(1500000),
305-
)
281+
p.create_reservation(start_time=_time(1200000), end_time=_time(1500000))
306282
assert p.get_schedule(from_time=_time(200000), to_time=_time(2500000)) == [
307283
quantum.QuantumTimeSlot(
308284
processor_name='test',
@@ -333,10 +309,7 @@ def test_create_reservation_add_at_end():
333309
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
334310
)
335311
p = NothingProcessor(processor_id='test', schedule=[time_slot])
336-
p.create_reservation(
337-
start_time=_time(2500000),
338-
end_time=_time(3500000),
339-
)
312+
p.create_reservation(start_time=_time(2500000), end_time=_time(3500000))
340313
assert p.get_schedule(from_time=_time(500000), to_time=_time(2500000)) == [
341314
quantum.QuantumTimeSlot(
342315
processor_name='test',
@@ -361,14 +334,8 @@ def test_create_reservation_border_conditions():
361334
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
362335
)
363336
p = NothingProcessor(processor_id='test', schedule=[time_slot])
364-
p.create_reservation(
365-
start_time=_time(1900000),
366-
end_time=_time(2000000),
367-
)
368-
p.create_reservation(
369-
start_time=_time(1000000),
370-
end_time=_time(1100000),
371-
)
337+
p.create_reservation(start_time=_time(1900000), end_time=_time(2000000))
338+
p.create_reservation(start_time=_time(1000000), end_time=_time(1100000))
372339
assert p.get_schedule(from_time=_time(200000), to_time=_time(2500000)) == [
373340
quantum.QuantumTimeSlot(
374341
processor_name='test',
@@ -403,14 +370,8 @@ def test_create_reservation_unbounded():
403370
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
404371
)
405372
p = NothingProcessor(processor_id='test', schedule=[time_slot_begin, time_slot_end])
406-
p.create_reservation(
407-
start_time=_time(1000000),
408-
end_time=_time(3000000),
409-
)
410-
p.create_reservation(
411-
start_time=_time(4000000),
412-
end_time=_time(6000000),
413-
)
373+
p.create_reservation(start_time=_time(1000000), end_time=_time(3000000))
374+
p.create_reservation(start_time=_time(4000000), end_time=_time(6000000))
414375
assert p.get_schedule(from_time=_time(200000), to_time=_time(10000000)) == [
415376
quantum.QuantumTimeSlot(
416377
processor_name='test',
@@ -449,14 +410,8 @@ def test_create_reservation_splitunbounded():
449410
time_slot_type=quantum.QuantumTimeSlot.TimeSlotType.UNALLOCATED,
450411
)
451412
p = NothingProcessor(processor_id='test', schedule=[time_slot_begin, time_slot_end])
452-
p.create_reservation(
453-
start_time=_time(1000000),
454-
end_time=_time(2000000),
455-
)
456-
p.create_reservation(
457-
start_time=_time(6000000),
458-
end_time=_time(7000000),
459-
)
413+
p.create_reservation(start_time=_time(1000000), end_time=_time(2000000))
414+
p.create_reservation(start_time=_time(6000000), end_time=_time(7000000))
460415
assert p.get_schedule(from_time=_time(200000), to_time=_time(10000000)) == [
461416
quantum.QuantumTimeSlot(
462417
processor_name='test',

Diff for: cirq-google/cirq_google/engine/abstract_processor.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -236,10 +236,7 @@ def run_calibration(
236236
"""
237237

238238
@abc.abstractmethod
239-
def get_sampler(
240-
self,
241-
gate_set: Optional['serializer.Serializer'] = None,
242-
) -> cirq.Sampler:
239+
def get_sampler(self, gate_set: Optional['serializer.Serializer'] = None) -> cirq.Sampler:
243240
"""Returns a sampler backed by the processor.
244241
245242
Args:
@@ -281,10 +278,7 @@ def get_device_specification(self) -> Optional[v2.device_pb2.DeviceSpecification
281278
"""
282279

283280
@abc.abstractmethod
284-
def get_device(
285-
self,
286-
gate_sets: Iterable['serializer.Serializer'] = (),
287-
) -> cirq.Device:
281+
def get_device(self, gate_sets: Iterable['serializer.Serializer'] = ()) -> cirq.Device:
288282
"""Returns a `Device` created from the processor's device specification.
289283
290284
This method queries the processor to retrieve the device specification,
@@ -329,9 +323,7 @@ def get_calibration(self, calibration_timestamp_seconds: int) -> calibration.Cal
329323
"""
330324

331325
@abc.abstractmethod
332-
def get_current_calibration(
333-
self,
334-
) -> Optional[calibration.Calibration]:
326+
def get_current_calibration(self) -> Optional[calibration.Calibration]:
335327
"""Returns metadata about the current calibration for a processor.
336328
337329
Returns:

Diff for: cirq-google/cirq_google/engine/engine.py

+3-11
Original file line numberDiff line numberDiff line change
@@ -138,11 +138,7 @@ def _serialize_program(
138138
raise ValueError(f'invalid program proto version: {self.proto_version}')
139139
return util.pack_any(serializer.serialize(program))
140140

141-
def _serialize_run_context(
142-
self,
143-
sweeps: 'cirq.Sweepable',
144-
repetitions: int,
145-
) -> any_pb2.Any:
141+
def _serialize_run_context(self, sweeps: 'cirq.Sweepable', repetitions: int) -> any_pb2.Any:
146142
if self.proto_version != ProtoVersion.V2:
147143
raise ValueError(f'invalid run context proto version: {self.proto_version}')
148144
return util.pack_any(v2.run_context_to_proto(sweeps, repetitions))
@@ -760,10 +756,7 @@ def list_processors(self) -> List[engine_processor.EngineProcessor]:
760756
response = self.context.client.list_processors(self.project_id)
761757
return [
762758
engine_processor.EngineProcessor(
763-
self.project_id,
764-
engine_client._ids_from_processor_name(p.name)[1],
765-
self.context,
766-
p,
759+
self.project_id, engine_client._ids_from_processor_name(p.name)[1], self.context, p
767760
)
768761
for p in response
769762
]
@@ -869,8 +862,7 @@ def get_engine_device(
869862

870863

871864
def get_engine_calibration(
872-
processor_id: str,
873-
project_id: Optional[str] = None,
865+
processor_id: str, project_id: Optional[str] = None
874866
) -> Optional['cirq_google.Calibration']:
875867
"""Returns calibration metrics for a given processor.
876868

0 commit comments

Comments
 (0)