Repository: quantumlib/Cirq

Issue:
Update code for when Engine metric qubits are formatted differently
There is currently code in calibration.py that looks at qubit ids that start with `q` and removes this `q` before getting the grid qubit.  If the API no longer returns `q` prefixed code this should be removed, otherwise if we are going to continue to support this we should add it to `grid_qubit_from_proto`.




Discussion:

Resolving patch:
diff --git a/cirq/google/engine/calibration.py b/cirq/google/engine/calibration.py
--- a/cirq/google/engine/calibration.py
+++ b/cirq/google/engine/calibration.py
@@ -67,12 +67,8 @@ def _compute_metric_dict(
                 getattr(v, v.WhichOneof('val')) for v in metric.values
             ]
             if metric.targets:
-                targets = [
-                    t[1:] if t.startswith('q') else t for t in metric.targets
-                ]
-                # TODO: Remove when calibrations don't prepend this.
-                # Github issue: https://github.com/quantumlib/Cirq/issues/2963
-                qubits = tuple(v2.grid_qubit_from_proto_id(t) for t in targets)
+                qubits = tuple(
+                    v2.grid_qubit_from_proto_id(t) for t in metric.targets)
                 results[name][qubits] = flat_values
             else:
                 assert len(results[name]) == 0, (


Test patch:
diff --git a/cirq/contrib/noise_models/noise_models_test.py b/cirq/contrib/noise_models/noise_models_test.py
--- a/cirq/contrib/noise_models/noise_models_test.py
+++ b/cirq/contrib/noise_models/noise_models_test.py
@@ -300,55 +300,55 @@ def test_aggregate_decay_noise_after_moment():
         }]
     }, {
         name: 'single_qubit_rb_pauli_error_per_gate',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: .001
         }]
     }, {
         name: 'single_qubit_rb_pauli_error_per_gate',
-        targets: ['q0_1'],
+        targets: ['0_1'],
         values: [{
             double_val: .002
         }]
     }, {
         name: 'single_qubit_rb_pauli_error_per_gate',
-        targets: ['q1_0'],
+        targets: ['1_0'],
         values: [{
             double_val: .003
         }]
     }, {
         name: 'single_qubit_readout_separation_error',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: .004
         }]
     }, {
         name: 'single_qubit_readout_separation_error',
-        targets: ['q0_1'],
+        targets: ['0_1'],
         values: [{
             double_val: .005
         }]
     }, {
         name: 'single_qubit_readout_separation_error',
-        targets: ['q1_0'],
+        targets: ['1_0'],
         values: [{
             double_val: .006
         }]
     }, {
         name: 'single_qubit_idle_t1_micros',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: .007
         }]
     }, {
         name: 'single_qubit_idle_t1_micros',
-        targets: ['q0_1'],
+        targets: ['0_1'],
         values: [{
             double_val: .008
         }]
     }, {
         name: 'single_qubit_idle_t1_micros',
-        targets: ['q1_0'],
+        targets: ['1_0'],
         values: [{
             double_val: .009
         }]
diff --git a/cirq/google/engine/calibration_test.py b/cirq/google/engine/calibration_test.py
--- a/cirq/google/engine/calibration_test.py
+++ b/cirq/google/engine/calibration_test.py
@@ -39,19 +39,19 @@
         }]
     }, {
         name: 't1',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: 321
         }]
     }, {
         name: 't1',
-        targets: ['q0_1'],
+        targets: ['0_1'],
         values: [{
             double_val: 911
         }]
     }, {
         name: 't1',
-        targets: ['q1_0'],
+        targets: ['1_0'],
         values: [{
             double_val: 505
         }]
diff --git a/cirq/google/engine/engine_job_test.py b/cirq/google/engine/engine_job_test.py
--- a/cirq/google/engine/engine_job_test.py
+++ b/cirq/google/engine/engine_job_test.py
@@ -269,7 +269,7 @@ def test_get_calibration(get_calibration):
         }]
     }, {
         name: 't1',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: 321
         }]
diff --git a/cirq/google/engine/engine_processor_test.py b/cirq/google/engine/engine_processor_test.py
--- a/cirq/google/engine/engine_processor_test.py
+++ b/cirq/google/engine/engine_processor_test.py
@@ -61,19 +61,19 @@ def _to_timestamp(json_string):
         }]
     }, {
         name: 't1',
-        targets: ['q0_0'],
+        targets: ['0_0'],
         values: [{
             double_val: 321
         }]
     }, {
         name: 't1',
-        targets: ['q0_1'],
+        targets: ['0_1'],
         values: [{
             double_val: 911
         }]
     }, {
         name: 't1',
-        targets: ['q1_0'],
+        targets: ['1_0'],
         values: [{
             double_val: 505
         }]