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

Make param ctrl_spec of get_ctrl_system mandatory #1209

Merged
merged 4 commits into from
Jul 30, 2024

Conversation

anurudhp
Copy link
Contributor

@anurudhp anurudhp commented Jul 30, 2024

Makes custom override code much cleaner as the user doesn't have to check for None.

For example, a custom single controlled version would look like:

def get_ctrl_system(self, ctrl_spec: 'CtrlSpec') -> Tuple['Bloq', 'AddControlledT']:
    if ctrl_spec != CtrlSpec(): # default fallback
        return super().get_ctrl_system(ctrl_spec=ctrl_spec)
    
    ... # custom single controlled version.

instead of

def get_ctrl_system(
    self, ctrl_spec: Optional['CtrlSpec'] = None
) -> Tuple['Bloq', 'AddControlledT']:
    if not (ctrl_spec is None or ctrl_spec == CtrlSpec()):
        return super().get_ctrl_system(ctrl_spec=ctrl_spec)

    ... # custom

This does not affect bloq users, who can still use bloq.controlled(). It only makes it simpler for bloq authors to provide custom versions.

Copy link
Collaborator

@tanujkhattar tanujkhattar left a comment

Choose a reason for hiding this comment

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

LGTM from my side -- The call site doesn't change with it; so users should still be able to do bloq.controlled() which is important.

cc @mpharrigan to see if there are any concerns and approve.

Copy link
Collaborator

@mpharrigan mpharrigan left a comment

Choose a reason for hiding this comment

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

lgtm, @anurudhp pinged me about this offline before :)

@anurudhp anurudhp enabled auto-merge (squash) July 30, 2024 19:49
@anurudhp anurudhp merged commit 2a78ca1 into quantumlib:main Jul 30, 2024
8 checks passed
@anurudhp anurudhp deleted the 2024/07/29-get-ctrl-system-param branch July 30, 2024 20:09
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants