Skip to content
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

Add support for serializing linear combinations of symbols #2358

Merged
merged 16 commits into from
Nov 8, 2019

Conversation

Strilanc
Copy link
Contributor

No description provided.

@Strilanc Strilanc requested a review from dabacon October 15, 2019 21:48
@googlebot googlebot added the cla: yes Makes googlebot stop complaining. label Oct 15, 2019
@dabacon dabacon requested a review from dstrain115 October 15, 2019 21:59
cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
cirq/google/op_serializer.py Outdated Show resolved Hide resolved
cirq/google/op_deserializer.py Outdated Show resolved Hide resolved
cirq/google/arg_func_langs.py Show resolved Hide resolved
@Strilanc
Copy link
Contributor Author

@dabacon PTAL. This has massively changed.

@Strilanc Strilanc added the Ready for Re-Review For when reviewers take their time. label Oct 19, 2019
cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
cirq/google/op_serializer.py Outdated Show resolved Hide resolved
cirq/google/arg_func_langs.py Show resolved Hide resolved
cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
cirq/google/serializable_gate_set.py Show resolved Hide resolved
cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
Copy link
Collaborator

@MichaelBroughton MichaelBroughton left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks really good, few minor things to consider. I'd still leave it to @dstrain115 for the final approval :)

cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
cirq/google/arg_func_langs.py Outdated Show resolved Hide resolved
cirq/google/arg_func_langs_test.py Show resolved Hide resolved
…arsing

# Conflicts:
#	cirq/google/op_deserializer.py
#	cirq/google/op_serializer.py
#	cirq/google/serializable_gate_set.py
Copy link
Collaborator

@dstrain115 dstrain115 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looked fine to me, except for a few nits.


# Argument types for gates. ArgFunction's are not currently supported.
ArgValue = Union[int, float, List[bool], str, sympy.Symbol]
SUPPORTED_FUNCTIONS_FOR_LANGUAGE: Dict[Optional[str], FrozenSet[str]] = {
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: SUPPORTED_FUNCTIONS_PER_LANGUAGE might be clearer?


msg = v2.program_pb2.Arg() if out is None else out

def check_support(func_type: str) -> str:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is there a good reason to inline this? We have many other _internal functions in this file. I personally don't like inlined functions, but maybe it is just a style preference.

@@ -12,9 +12,211 @@
# See the License for the specific language governing permissions and
# limitations under the License.

from typing import List, Union
from typing import (
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

why the extra ','? If you remove that it will wrap nicer, right? For imports these long lists are annoying.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. I prefer the vertical list style to the block style, as it makes git diffs cleaner.


Args:
arg_proto: The proto containing a serialized value.
required_arg_name: If set to `None`, the method will return `None` when
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: order does not match arg order

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Fixed.

Dict,
Optional,
Sequence,
TYPE_CHECKING,
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: remove comma to get formatting that doesn't fill up my screen when I open the file :)

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Acknowledged. I prefer the vertical list style to the block style, as it makes git diffs cleaner.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think the white space is a big waste. Plus no one else is doing this in the code base.

@Strilanc Strilanc removed the Ready for Re-Review For when reviewers take their time. label Nov 8, 2019
@Strilanc Strilanc added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Nov 8, 2019
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Nov 8, 2019
@CirqBot CirqBot merged commit 5207900 into master Nov 8, 2019
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Nov 8, 2019
@CirqBot CirqBot deleted the linearcomboparsing branch November 8, 2019 18:37
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Nov 8, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
cla: yes Makes googlebot stop complaining.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

6 participants