Qiskit / qiskit

Qiskit is an open-source SDK for working with quantum computers at the level of extended quantum circuits, operators, and primitives.
https://www.ibm.com/quantum/qiskit
Apache License 2.0
5.31k stars 2.38k forks source link

LaTex rendering fails #6958

Closed af-rotundo closed 3 years ago

af-rotundo commented 3 years ago

Information

What is the current behavior?

I'm trying to draw the following simple circuit with LaTex

simpleCircuit

However, the output is empty when I pass the option output='latex'.

The problem is only present with the Initialize gate. Also, the problem is not present for different numbers of quantum/classical registers, e.g. the circuit is drawn correctly if one quantum register is removed.

Steps to reproduce the problem

Run the following code in JupyterLab

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import random_statevector
from qiskit.extensions import Initialize

qr = QuantumRegister(5, name="q")
cr1, cr2 = ClassicalRegister(1, name="cr1"), ClassicalRegister(1, name="cr2")
scr = QuantumCircuit(qr,cr1,cr2)
psi = random_statevector(2)
init_gate = Initialize(psi)
scr.append(init_gate, [0])
scr.draw(output='latex')

What is the expected behavior?

For example if we remove one quantum register, the circuit is rendered correctly. Try

from qiskit import QuantumCircuit, QuantumRegister, ClassicalRegister
from qiskit.quantum_info import random_statevector
from qiskit.extensions import Initialize

qr = QuantumRegister(4, name="q")
cr1, cr2 = ClassicalRegister(1, name="cr1"), ClassicalRegister(1, name="cr2")
scr = QuantumCircuit(qr,cr1,cr2)
psi = random_statevector(2)
init_gate = Initialize(psi)
scr.append(init_gate, [0])
scr.draw(output='latex')

Suggested solutions

epelaaez commented 3 years ago

Using the following Qiskit version (the one from the IBM Quantum Lab):

{'qiskit-terra': '0.18.1', 'qiskit-aer': '0.8.2', 'qiskit-ignis': '0.6.0', 'qiskit-ibmq-provider': '0.16.0', 'qiskit-aqua': '0.9.4', 'qiskit': '0.29.0', 'qiskit-nature': '0.1.5', 'qiskit-finance': '0.2.0', 'qiskit-optimization': '0.2.1', 'qiskit-machine-learning': '0.2.0'}

I'm able to get the drawing you're having trouble with: image

It probably has something to do with you using 0.17.1.

af-rotundo commented 3 years ago

The problem was indeed the outdated package, thanks.