Qiskit-terra: circuit without gates cannot be drew on latex

Created on 3 Sep 2020  路  6Comments  路  Source: Qiskit/qiskit-terra

Information

  • Qiskit Terra version: master
  • Python version: 3.7
  • Operating system: MacOS

Steps to reproduce the problem

from qiskit import *
qc = QuantumCircuit(2)
qc.draw('latex')
IndexError: list index out of range



md5-f4a75be27ea1eb0358f50c4d31e3b348



q_0:

q_1:


```python
qc.draw('mpl')

image

bug good first issue

All 6 comments

@1ucian0 Maybe I can help with this, would that be ok?

Sure! Thanks!

Perfect, I'll start taking a look later today.
Thanks!

Fwiw, this used to work fine. It looks this was a regression introduced in: https://github.com/Qiskit/qiskit-terra/pull/4410

Yeah, the issue seems to be that "self.ops" is empty, but its first element is checked in if self.cregbundle and self.ops[0][0].name == "measure"
https://github.com/Qiskit/qiskit-terra/blob/master/qiskit/visualization/latex.py#L302

Now, if I have understood correctly, self.ops is the list of layers in the circuit: @1ucian0 is it supposed to be empty for a QuantumCircuit?
I noticed in text.py it's handled differently (called instructions there, but still, if I'm not mistaken...), so my guess is that it's OK and it's fine just making sure the list isn't empty, is that right?

Sounds good to me. Let's discuss it in a PR 馃槉

Was this page helpful?
0 / 5 - 0 ratings