-
Notifications
You must be signed in to change notification settings - Fork 1.2k
Add boolean support to cirq_google protos #7177
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from 1 commit
ca0019b
fb61a16
9f77bc9
0eda067
f56bb61
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -128,7 +128,9 @@ def arg_to_proto( | |
| """ | ||
| msg = v2.program_pb2.Arg() if out is None else out | ||
|
|
||
| if isinstance(value, FLOAT_TYPES): | ||
| if isinstance(value, bool): | ||
|
Collaborator
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. on line 146, there is a check for
Collaborator
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Done. |
||
| msg.arg_value.bool_value = value | ||
| elif isinstance(value, FLOAT_TYPES): | ||
| msg.arg_value.float_value = float(value) | ||
| elif isinstance(value, str): | ||
| msg.arg_value.string_value = value | ||
|
|
@@ -274,6 +276,8 @@ def arg_from_proto( | |
| if math.ceil(result) == math.floor(result): | ||
| result = int(result) | ||
| return result | ||
| if which_val == 'bool_value': | ||
| return bool(arg_value.bool_value) | ||
| if which_val == 'bool_values': | ||
| return list(arg_value.bool_values.values) | ||
| if which_val == 'string_value': | ||
|
|
||
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
nit: can we move this field next to
bool_valuesfor better discoverability in the future. (I'm aware this convention hasn't been done before.)There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I don't think that's a good idea. I think it's generally better to keep things in order of field id unless there's a really good reason. Otherwise, it gets more confusing to add fields.