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

[text drawer] controlled gates with labels #4361

Closed
1ucian0 opened this issue Apr 30, 2020 · 5 comments · Fixed by #4420
Closed

[text drawer] controlled gates with labels #4361

1ucian0 opened this issue Apr 30, 2020 · 5 comments · Fixed by #4420
Labels
bug Something isn't working

Comments

@1ucian0
Copy link
Member

1ucian0 commented Apr 30, 2020

@ewinston raises the question on how to handle controlled gates with labels in #4262 (review).

Considering this case:

h=HGate(label='my h')
ch = h.control(label='my ch')
qc.append(h, [0])
qc.append(ch, [0, 1])

This is the current output:

     ┌──────┐┌────────┐
q_0: ┤ my h ├┤0       ├
     └──────┘│  my ch │
q_1: ────────┤1       ├
             └────────┘

Possible solutions:

     ┌──────┐ my ch
q_0: ┤ my h ├───■─────
     └──────┘┌──┴───┐
q_1: ────────┤ my h ├─
             └──────┘
     ┌──────┐
q_0: ┤ my h ├───■─────────
     └──────┘┌──┴my ch───┐
q_1: ────────┤    my h   ├
             └───────────┘
@enavarro51
Copy link
Contributor

@1ucian0 I was looking at how to add labels to the mpl drawer and I had a question about how they are implemented. Given these 3 statements,

1 - qc.append(HGate(label='My ch Gate').control(1, label='My ch Control')
2 - qc.append(HGate(label='My ch Gate').control(1)
3 - qc.append(HGate().control(1,label='My ch Control')

It appears that in line 3, the label gets placed into op.label whereas in line 1, it's placed in op.base_gate.label. I noticed in the text drawer that line 1 produces 'My ch Gate' in the gate name and 'My ch Control' on the bullet, but in line 3, it creates a multi-box and changes the name of the gate to 'My ch Control'.

This seems odd to me. If the user wanted to change the gate name, I would think that line 1 or 2 would be used, and if the intention is to add a control label to an existing gate name, line 1 or 3 would be used.

In any case, I'd just like some guidance on how this should look in mpl. There are more options for putting text in different places in mpl than in text, so if there were some way do line 3 as op.base_gate.name for the gate name and putting the control name on the bullet, that seems most logical to me.

Thanks for your help.

@1ucian0
Copy link
Member Author

1ucian0 commented Jun 11, 2020

...but in line 3, it creates a multi-box and changes the name of the gate to 'My ch Control'.

I agree it is inconsistent. Do you mind submitting an enhancement issue for that?

In any case, I'd just like some guidance on how this should look in mpl.

I dont have an opinion there. Maybe the best way to move forward is to submit an issue (tagged discussion with examples and options. In that way, we can hear other people's options.

What do you think?

@enavarro51
Copy link
Contributor

Thanks, @1ucian0. I'll go ahead and put my thoughts in an enhancement issue. I just wanted to check to see that there wasn't some big picture I was missing.

@scottwn
Copy link
Contributor

scottwn commented Jun 12, 2020

@enavarro51 could you link the enhancement issue here when you open it?

@enavarro51
Copy link
Contributor

Will do.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Development

Successfully merging a pull request may close this issue.

3 participants