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

Clean up _resolve_parameters_ method signatures #3925

Merged
merged 3 commits into from
Mar 18, 2021

Conversation

maffoo
Copy link
Contributor

@maffoo maffoo commented Mar 17, 2021

Follow-up to #3922. Clean up _resolve_parameters_ method signatures by adding types where appropriate and using consistent argument names.

Add types where appropriate and use consistent argument names
@maffoo maffoo requested review from cduck, vtomole and a team as code owners March 17, 2021 21:09
@google-cla google-cla bot added the cla: yes Makes googlebot stop complaining. label Mar 17, 2021
Copy link
Collaborator

@95-martin-orion 95-martin-orion left a comment

Choose a reason for hiding this comment

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

One nit, otherwise LGTM.

Thanks for this cleanup! I feel at least partly responsible following my "recursive parameter resolution" rampage :P

return self._with_exponent(exponent=param_resolver.value_of(self._exponent, recursive))
def _resolve_parameters_(
self: TSelf, resolver: 'cirq.ParamResolver', recursive: bool
) -> 'EigenGate':
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be TSelf instead of EigenGate, to match self?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I tried that, but it doesn't work because self._with_exponent does not return TSelf. If you change that also, there are problems with eigengate subclasses like _PauliX since those can return a different type when the exponent is changed (e.g. a generic XPowGate in stead of _PauliX). I think we'll have to live with the less specific types here. I did remove the TSelf annotation here since it wasn't doing anything.

Copy link
Collaborator

Choose a reason for hiding this comment

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

SGTM.

@maffoo maffoo added the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 18, 2021
@CirqBot CirqBot added the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 18, 2021
@CirqBot CirqBot merged commit 47f5908 into master Mar 18, 2021
@CirqBot CirqBot removed the automerge Tells CirqBot to sync and merge this PR. (If it's running.) label Mar 18, 2021
@CirqBot CirqBot deleted the u/maffoo/resolve-params branch March 18, 2021 19:55
@CirqBot CirqBot removed the front_of_queue_automerge CirqBot uses this label to indicate (and remember) what's being merged next. label Mar 18, 2021
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.

None yet

3 participants