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

Display of controlled composite gates appears incorrect. #3546

Closed
ewinston opened this issue Dec 3, 2019 · 2 comments · Fixed by #3771
Closed

Display of controlled composite gates appears incorrect. #3546

ewinston opened this issue Dec 3, 2019 · 2 comments · Fixed by #3771
Assignees
Labels
bug Something isn't working priority: medium status: pending PR It has one or more PRs pending to solve this issue
Milestone

Comments

@ewinston
Copy link
Contributor

ewinston commented Dec 3, 2019

Information

  • Qiskit Terra version:
  • Python version:
  • Operating system:

What is the current behavior?

Controlled composite gates appear with the wrong number of controls.

Steps to reproduce the problem

qc1 = QuantumCircuit(3, name='ghz')
qc1.h(0)
qc1.cx(0, 1)
qc1.cx(1, 2)
ghz = qc1.to_gate()
cghz = ghz.control(1)
qc2 = QuantumCircuit(4)
qc2.append(cghz, [1, 0, 2, 3])
print(qc2)

results in,

               
q_0: |0>───■───
           │   
q_1: |0>───■───
           │   
q_2: |0>───■───
        ┌──┴──┐
q_3: |0>┤ Ghz ├
        └─────┘

What is the expected behavior?

The number of controls should be num_ctrl_qubits. The exception might be if the gate being controlled is itself a controlled gate. For instance a gate like x.control().control() would show two control qubits.

Suggested solutions

@1ucian0
Copy link
Member

1ucian0 commented Dec 4, 2019

The expected result is this (see #3199)?

         ┌──────┐
q_0: |0>─┤1     ├ 
         │      │ 
q_1: |0>─■      ├
         │  Ghz │
q_2: |0>─┤2     ├
         │      │
q_3: |0>─┤3     ├
         └──────┘

@1ucian0 1ucian0 added bug Something isn't working priority: medium labels Dec 4, 2019
@ewinston
Copy link
Contributor Author

ewinston commented Dec 4, 2019

That looks better.

@kdk kdk modified the milestone: 0.11 Dec 5, 2019
@1ucian0 1ucian0 self-assigned this Dec 9, 2019
@1ucian0 1ucian0 added this to the 0.12 milestone Dec 9, 2019
1ucian0 pushed a commit to 1ucian0/qiskit-terra that referenced this issue Jan 30, 2020
@1ucian0 1ucian0 added the status: pending PR It has one or more PRs pending to solve this issue label Jan 31, 2020
@mergify mergify bot closed this as completed in #3771 Jan 31, 2020
mergify bot pushed a commit that referenced this issue Jan 31, 2020
* instruction.op.num_ctrl_qubits

* controlled_wires for knowing if controlled qubits sholud be at the edge

* in, out, rest

* OnWireMid with control_label

* order in the paramenters

* #3546 test

* lint

* failing test

* improve the connector

* test control on top and bot

* connectors to multibox, hackish

* failing test

* fix

* lint

* release notes
faisaldebouni pushed a commit to faisaldebouni/qiskit-terra that referenced this issue Aug 5, 2020
* instruction.op.num_ctrl_qubits

* controlled_wires for knowing if controlled qubits sholud be at the edge

* in, out, rest

* OnWireMid with control_label

* order in the paramenters

* Qiskit#3546 test

* lint

* failing test

* improve the connector

* test control on top and bot

* connectors to multibox, hackish

* failing test

* fix

* lint

* release notes
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working priority: medium status: pending PR It has one or more PRs pending to solve this issue
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants