diff --git a/cirq-google/cirq_google/devices/grid_device_test.py b/cirq-google/cirq_google/devices/grid_device_test.py index 547e9d03ce5..c2f645d7270 100644 --- a/cirq-google/cirq_google/devices/grid_device_test.py +++ b/cirq-google/cirq_google/devices/grid_device_test.py @@ -418,7 +418,14 @@ def test_to_proto_invalid_input(error_match, qubits, qubit_pairs, gateset, gate_ def test_to_proto_backward_compatibility(): - with cirq.testing.assert_deprecated('SerializableGateSet', deadline='v0.16', count=None): + # Deprecations: cirq_google.SerializableGateSet and + # cirq_google.device.known_devices.create_device_proto_for_qubits() + with cirq.testing.assert_deprecated( + 'SerializableGateSet', + 'create_device_specification_proto()` can be used', + deadline='v0.16', + count=None, + ): device_info, _ = _create_device_spec_with_horizontal_couplings() # The set of gates in gate_durations are consistent with what's generated in diff --git a/cirq-google/cirq_google/devices/known_devices.py b/cirq-google/cirq_google/devices/known_devices.py index 0532486ada3..2816dcd2e8c 100644 --- a/cirq-google/cirq_google/devices/known_devices.py +++ b/cirq-google/cirq_google/devices/known_devices.py @@ -124,6 +124,13 @@ def _create_grid_device_from_diagram( return grid_device.GridDevice.from_proto(device_specification) +@_compat.deprecated( + deadline='v0.16', + fix='This function will no longer be available.' + ' `cirq_google.grid_device.create_device_specification_proto()` can be used' + ' to generate a DeviceSpecification proto which matches the format expected' + ' by GridDevice.', +) def create_device_proto_for_qubits( qubits: Collection[cirq.Qid], pairs: Collection[Tuple[cirq.Qid, cirq.Qid]], diff --git a/cirq-google/cirq_google/devices/known_devices_test.py b/cirq-google/cirq_google/devices/known_devices_test.py index 35cd357e22a..3dfbf64ccbd 100644 --- a/cirq-google/cirq_google/devices/known_devices_test.py +++ b/cirq-google/cirq_google/devices/known_devices_test.py @@ -28,10 +28,13 @@ def test_create_device_proto_for_irregular_grid(): (cirq.GridQubit(0, 0), cirq.GridQubit(1, 0)), (cirq.GridQubit(1, 0), cirq.GridQubit(1, 1)), ] - proto = known_devices.create_device_proto_for_qubits(qubits, pairs) - assert ( - str(proto) - == """\ + with cirq.testing.assert_deprecated( + 'create_device_specification_proto()` can be used', deadline='v0.16', count=1 + ): + proto = known_devices.create_device_proto_for_qubits(qubits, pairs) + assert ( + str(proto) + == """\ valid_qubits: "0_0" valid_qubits: "0_1" valid_qubits: "1_0" @@ -57,7 +60,7 @@ def test_create_device_proto_for_irregular_grid(): } } """ - ) + ) def test_multiple_gate_sets(): @@ -65,7 +68,7 @@ def test_multiple_gate_sets(): # well-known cirq_google SerializableGateSets (e.g. cirq_google.SYC_GATESET), and # cirq_google.devices.known_devices.create_device_proto_from_diagram with cirq.testing.assert_deprecated( - 'SerializableGateSet', 'no longer be available', deadline='v0.16', count=3 + 'SerializableGateSet', 'no longer be available', deadline='v0.16', count=4 ): halfPiGateSet = cirq_google.SerializableGateSet( gate_set_name='half_pi_gateset', @@ -234,7 +237,7 @@ def test_sycamore_circuitop_device(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=6, + count=7, ): circuitop_gateset = cirq_google.SerializableGateSet( gate_set_name='circuitop_gateset', @@ -281,7 +284,7 @@ def test_proto_with_circuitop(): # Deprecations: cirq_google.SerializableGateSets class and # cirq_google.devices.known_devices.create_device_proto_from_diagram with cirq.testing.assert_deprecated( - 'SerializableGateSet', 'no longer be available', deadline='v0.16', count=2 + 'SerializableGateSet', 'no longer be available', deadline='v0.16', count=3 ): circuitop_gateset = cirq_google.SerializableGateSet( gate_set_name='circuitop_gateset', @@ -341,7 +344,7 @@ def test_proto_with_waitgate(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=4, + count=5, ): wait_gateset = cirq_google.SerializableGateSet( gate_set_name='wait_gateset', @@ -412,7 +415,7 @@ def test_adding_gates_multiple_times(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=4, + count=5, ): waiting_for_godot = cirq_google.SerializableGateSet( gate_set_name='wait_gateset', diff --git a/cirq-google/cirq_google/devices/serializable_device_test.py b/cirq-google/cirq_google/devices/serializable_device_test.py index 493a9821ad6..bdaf61d1231 100644 --- a/cirq-google/cirq_google/devices/serializable_device_test.py +++ b/cirq-google/cirq_google/devices/serializable_device_test.py @@ -59,10 +59,15 @@ def _just_meas(): def test_str_with_grid_qubits(): - # Deprecations: cirq_google.SerializableDevice and well-known cirq_google SerializableGateSets - # (e.g. cirq_google.SYC_GATESET) + # Deprecations: cirq_google.SerializableDevice, well-known cirq_google SerializableGateSets + # (e.g. cirq_google.SYC_GATESET) and + # cirq_google.devices.known_devices.create_device_proto_for_qubits with cirq.testing.assert_deprecated( - 'Use cirq_google.GridDevice', 'SerializableGateSet', deadline='v0.16', count=4 + 'Use cirq_google.GridDevice', + 'SerializableGateSet', + 'create_device_specification_proto()` can be used', + deadline='v0.16', + count=5, ): qubits = cirq.GridQubit.rect(2, 3, left=1, top=1) device_proto = cgdk.create_device_proto_for_qubits( @@ -94,9 +99,16 @@ def test_repr_pretty(cycle, func): def test_metadata_correct(): - # Deprecations: cirq_google.SerializableDevice and well-known cirq_google SerializableGateSets - # (e.g. cirq_google.SYC_GATESET) - with cirq.testing.assert_deprecated('Use cirq_google.GridDevice', deadline='v0.16', count=4): + # Deprecations: cirq_google.SerializableDevice, well-known cirq_google SerializableGateSets + # (e.g. cirq_google.SYC_GATESET) and + # cirq_google.devices.known_devices.create_device_proto_for_qubits + with cirq.testing.assert_deprecated( + 'Use cirq_google.GridDevice', + 'SerializableGateSet', + 'create_device_specification_proto()` can be used', + deadline='v0.16', + count=5, + ): qubits = cirq.GridQubit.rect(2, 3, left=1, top=1) pairs = [ (qubits[0], qubits[1]), @@ -161,7 +173,7 @@ def test_mismatched_proto_serializer(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=5, + count=6, ): augmented_proto = cgdk.create_device_proto_from_diagram( cgdk._SYCAMORE_GRID, @@ -186,7 +198,7 @@ def test_named_qubit(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=6, + count=7, ): augmented_proto = cgdk.create_device_proto_from_diagram( cgdk._SYCAMORE_GRID, @@ -211,7 +223,7 @@ def test_duration_of(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=5, + count=6, ): valid_qubit1 = cirq.GridQubit(0, 0) @@ -382,7 +394,7 @@ def test_multiple_gatesets(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=5, + count=6, ): halfPiGateSet = cirq_google.SerializableGateSet( gate_set_name='half_pi_gateset', @@ -424,7 +436,7 @@ def test_half_pi_takes_half_duration(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=4, + count=5, ): half_pi_gs = cirq_google.SerializableGateSet( gate_set_name='half_pi', @@ -457,7 +469,7 @@ def test_multiple_fsim_gatesets(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=4, + count=5, ): half_pi_gs = cirq_google.SerializableGateSet( gate_set_name='half_pi', @@ -487,7 +499,7 @@ def test_serializable_device_str_grid_qubits(): 'SerializableGateSet', 'no longer be available', deadline='v0.16', - count=5, + count=6, ): spec = cirq_google.devices.known_devices.create_device_proto_from_diagram( "aa\naa", [cg.SYC_GATESET]