diff --git a/cirq-google/cirq_google/api/v2/run_context.proto b/cirq-google/cirq_google/api/v2/run_context.proto index 759679a92c6..d996c9c57a8 100644 --- a/cirq-google/cirq_google/api/v2/run_context.proto +++ b/cirq-google/cirq_google/api/v2/run_context.proto @@ -217,7 +217,6 @@ message Const { oneof value { // This value should always be true if set, which represent the python None object. bool is_none = 1; - float float_value = 2; int64 int_value = 3; string string_value = 4; diff --git a/cirq-google/cirq_google/api/v2/sweeps.py b/cirq-google/cirq_google/api/v2/sweeps.py index 4a12394b7be..cc4eb801c60 100644 --- a/cirq-google/cirq_google/api/v2/sweeps.py +++ b/cirq-google/cirq_google/api/v2/sweeps.py @@ -91,6 +91,8 @@ def sweep_to_proto( out.single_sweep.parameter.units = sweep.metadata.units elif isinstance(sweep, cirq.Points) and not isinstance(sweep.key, sympy.Expr): out.single_sweep.parameter_key = sweep.key + # Encoding the sinlge sweep with None to avoid the behavior modification. + # May remove the `sweep.points[0] is None` condition in future. if len(sweep.points) == 1 and sweep.points[0] is None: out.single_sweep.const.MergeFrom(_build_sweep_const(sweep.points[0])) else: diff --git a/cirq-google/cirq_google/api/v2/sweeps_test.py b/cirq-google/cirq_google/api/v2/sweeps_test.py index c2f5152c464..af5f0cf76a6 100644 --- a/cirq-google/cirq_google/api/v2/sweeps_test.py +++ b/cirq-google/cirq_google/api/v2/sweeps_test.py @@ -105,7 +105,7 @@ def test_sweep_to_proto_linspace(): def test_build_recover_const(val): val2 = v2.sweeps._recover_sweep_const(v2.sweeps._build_sweep_const(val)) if isinstance(val, float): - assert math.isclose(val, val2) + assert math.isclose(val, val2) # avoid the floating precision issue. else: assert val2 == val