-
Notifications
You must be signed in to change notification settings - Fork 988
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
Conversation
Add types where appropriate and use consistent argument names
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.
One nit, otherwise LGTM.
Thanks for this cleanup! I feel at least partly responsible following my "recursive parameter resolution" rampage :P
cirq/ops/eigen_gate.py
Outdated
return self._with_exponent(exponent=param_resolver.value_of(self._exponent, recursive)) | ||
def _resolve_parameters_( | ||
self: TSelf, resolver: 'cirq.ParamResolver', recursive: bool | ||
) -> 'EigenGate': |
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.
Should this be TSelf
instead of EigenGate
, to match self
?
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 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.
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.
SGTM.
Follow-up to #3922. Clean up
_resolve_parameters_
method signatures by adding types where appropriate and using consistent argument names.