Skip to content

Commit

Permalink
Add deprecation context in tests that use SerializableDevice
Browse files Browse the repository at this point in the history
  • Loading branch information
verult committed Jun 22, 2022
1 parent 93c13df commit cc5246f
Show file tree
Hide file tree
Showing 2 changed files with 44 additions and 28 deletions.
54 changes: 29 additions & 25 deletions cirq-google/cirq_google/devices/grid_device_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -459,33 +459,37 @@ def test_to_proto_backward_compatibility():
out=spec,
)

# Deserialize both ways
serializable_dev = cirq_google.SerializableDevice.from_proto(spec, [cirq_google.FSIM_GATESET])
grid_dev = cirq_google.GridDevice.from_proto(spec)

assert serializable_dev.metadata.qubit_set == grid_dev.metadata.qubit_set
assert serializable_dev.metadata.qubit_pairs == grid_dev.metadata.qubit_pairs

assert serializable_dev.metadata.gateset == cirq.Gateset(
cirq.FSimGate,
cirq.ISwapPowGate,
cirq.CZPowGate,
cirq.PhasedXPowGate,
cirq.XPowGate,
cirq.YPowGate,
cirq.ZPowGate,
cirq.PhasedXZGate,
cirq.MeasurementGate,
cirq.WaitGate,
cirq.GlobalPhaseGate,
)
with cirq.testing.assert_deprecated('Use cirq_google.GridDevice', deadline='v0.16', count=None):
# Deserialize both ways
serializable_dev = cirq_google.SerializableDevice.from_proto(
spec, [cirq_google.FSIM_GATESET]
)
grid_dev = cirq_google.GridDevice.from_proto(spec)

assert serializable_dev.metadata.qubit_set == grid_dev.metadata.qubit_set
assert serializable_dev.metadata.qubit_pairs == grid_dev.metadata.qubit_pairs

assert serializable_dev.metadata.gateset == cirq.Gateset(
cirq.FSimGate,
cirq.ISwapPowGate,
cirq.CZPowGate,
cirq.PhasedXPowGate,
cirq.XPowGate,
cirq.YPowGate,
cirq.ZPowGate,
cirq.PhasedXZGate,
cirq.MeasurementGate,
cirq.WaitGate,
cirq.GlobalPhaseGate,
)

assert grid_dev.metadata.gateset == device_info.expected_gateset
assert (
tuple(grid_dev.metadata.compilation_target_gatesets) == device_info.expected_target_gatesets
)
assert grid_dev.metadata.gateset == device_info.expected_gateset
assert (
tuple(grid_dev.metadata.compilation_target_gatesets)
== device_info.expected_target_gatesets
)

assert grid_dev.metadata.gate_durations == device_info.expected_gate_durations
assert grid_dev.metadata.gate_durations == device_info.expected_gate_durations


def test_to_proto_empty():
Expand Down
18 changes: 15 additions & 3 deletions cirq-google/cirq_google/devices/known_devices_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -221,7 +221,11 @@ def test_multiple_gate_sets():


def test_sycamore_circuitop_device():
with cirq.testing.assert_deprecated('no longer be available', deadline='v0.16', count=1):
# Deprecations: cirq_google.SerializableDevice and
# cirq_google.devices.known_devices.create_device_proto_from_diagram
with cirq.testing.assert_deprecated(
'Use cirq_google.GridDevice', 'no longer be available', deadline='v0.16', count=3
):
circuitop_gateset = cirq_google.SerializableGateSet(
gate_set_name='circuitop_gateset',
serializers=[cgc.CIRCUIT_OP_SERIALIZER],
Expand Down Expand Up @@ -316,7 +320,11 @@ def test_proto_with_circuitop():


def test_proto_with_waitgate():
with cirq.testing.assert_deprecated('no longer be available', deadline='v0.16', count=1):
# Deprecations: cirq_google.SerializableDevice and
# cirq_google.devices.known_devices.create_device_proto_from_diagram
with cirq.testing.assert_deprecated(
'Use cirq_google.GridDevice', 'no longer be available', deadline='v0.16', count=3
):
wait_gateset = cirq_google.SerializableGateSet(
gate_set_name='wait_gateset',
serializers=[cgc.WAIT_GATE_SERIALIZER],
Expand Down Expand Up @@ -379,7 +387,11 @@ def test_proto_with_waitgate():


def test_adding_gates_multiple_times():
with cirq.testing.assert_deprecated('no longer be available', deadline='v0.16', count=1):
# Deprecations: cirq_google.SerializableDevice and
# cirq_google.devices.known_devices.create_device_proto_from_diagram
with cirq.testing.assert_deprecated(
'Use cirq_google.GridDevice', 'no longer be available', deadline='v0.16', count=3
):
waiting_for_godot = cirq_google.SerializableGateSet(
gate_set_name='wait_gateset',
serializers=[
Expand Down

0 comments on commit cc5246f

Please sign in to comment.