def test_converting_multiple_device_params_to_device_parameters_diff() -> None:
    """Test of converting a list of DeviceParameter's to a DeviceParametersDiff object."""
    readout_paths = (["q3_4", "readout_default"], ["q5_6", "readout_default"])

    device_params: list[
        tuple[
            run_context_pb2.DeviceParameter,
            program_pb2.ArgValue | run_context_pb2.DeviceParametersDiff.GenericValue,
        ]
    ] = []
    for readout_path in readout_paths:
        device_params.extend(
            [
                (
                    run_context_pb2.DeviceParameter(
                        path=[*readout_path, "readoutDemodDelay"], units="ns"
                    ),
                    program_pb2.ArgValue(float_value=5.0),
                ),
                (
                    run_context_pb2.DeviceParameter(path=[*readout_path, "readoutFidelities"]),
                    program_pb2.ArgValue(
                        double_values=program_pb2.RepeatedDouble(values=[0.991, 0.993])
                    ),
                ),
                (
                    run_context_pb2.DeviceParameter(path=[*readout_path, "readoutCenters"]),
                    run_context_pb2.DeviceParametersDiff.GenericValue(
                        type_descriptor="tuple[complex, complex]", value=b"(-1.0+2.0i, 3.0-4.0i)"
                    ),
                ),
                (
                    run_context_pb2.DeviceParameter(path=[*readout_path, "demod", "phase_i_rad"]),
                    program_pb2.ArgValue(double_value=0.0),
                ),
            ]
        )
    diff = run_context.to_device_parameters_diff(device_params)
    expected_diff_pb_text = """
        groups {
          parent: -1
        }
        groups {
          name: 1
        }
        groups {
          parent: 1
          name: 5
        }
        groups {
          parent: -1
          name: 7
        }
        groups {
          parent: 3
          name: 1
        }
        groups {
          parent: 4
          name: 5
        }
        params {
          resource_group: 1
          name: 2
          value {
            float_value: 5
          }
        }
        params {
          resource_group: 1
          name: 3
          value {
            double_values {
              values: 0.991
              values: 0.993
            }
          }
        }
        params {
          resource_group: 1
          name: 4
          generic_value {
            type_descriptor: "tuple[complex, complex]"
            value: "(-1.0+2.0i, 3.0-4.0i)"
          }
        }
        params {
          resource_group: 2
          name: 6
          value {
            double_value: 0
          }
        }
        params {
          resource_group: 4
          name: 2
          value {
            float_value: 5
          }
        }
        params {
          resource_group: 4
          name: 3
          value {
            double_values {
              values: 0.991
              values: 0.993
            }
          }
        }
        params {
          resource_group: 4
          name: 4
          generic_value {
            type_descriptor: "tuple[complex, complex]"
            value: "(-1.0+2.0i, 3.0-4.0i)"
          }
        }
        params {
          resource_group: 5
          name: 6
          value {
            double_value: 0
          }
        }
        strs: "q3_4"
        strs: "readout_default"
        strs: "readoutDemodDelay"
        strs: "readoutFidelities"
        strs: "readoutCenters"
        strs: "demod"
        strs: "phase_i_rad"
        strs: "q5_6"
    """
    assert text_format.Parse(expected_diff_pb_text, run_context_pb2.DeviceParametersDiff()) == diff
Test of converting a list of DeviceParameter's to a DeviceParametersDiff object.
cirq-google/cirq_google/api/v2/run_context_test.py