Skip to content

Commit

Permalink
Address the comment
Browse files Browse the repository at this point in the history
  • Loading branch information
BichengYing committed Sep 16, 2024
1 parent 7f808d1 commit aac1337
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 2 deletions.
1 change: 0 additions & 1 deletion cirq-google/cirq_google/api/v2/run_context.proto
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down
2 changes: 2 additions & 0 deletions cirq-google/cirq_google/api/v2/sweeps.py
Original file line number Diff line number Diff line change
Expand Up @@ -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:
Expand Down
2 changes: 1 addition & 1 deletion cirq-google/cirq_google/api/v2/sweeps_test.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down

0 comments on commit aac1337

Please sign in to comment.