Repository: Qiskit/qiskit

Issue:
Text circuit drawer raises ValueError if an empty circuit is given
<!-- ⚠️ If you do not respect this template, your issue will be closed -->
<!-- ⚠️ Make sure to browse the opened and closed issues -->

### Information

- **Qiskit Terra version**: 0.7.3
- **Python version**: 3.6.8
- **Operating system**: macOS HighSierra

### What is the current behavior?

If I try to draw an empty circuit with the text drawer, it raises ValueError.

### Steps to reproduce the problem

```
# sample.py
from qiskit import QuantumCircuit
qc = QuantumCircuit()
print(qc)
```

```
$ python sample.py
Traceback (most recent call last):
  File "c.py", line 3, in <module>
    print(qc)
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/circuit/quantumcircuit.py", line 83, in __str__
    return str(self.draw(output='text'))
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/tools/visualization/_text.py", line 413, in __str__
    return self.single_string()
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/tools/visualization/_text.py", line 438, in single_string
    return "\n".join(self.lines())
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/tools/visualization/_text.py", line 472, in lines
    layers = self.build_layers()
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/tools/visualization/_text.py", line 672, in build_layers
    layers.append(InputWire.fillup_layer(self.wire_names(with_initial_value=True)))
  File "/Users/ima/envs/vqe2/lib/python3.6/site-packages/qiskit/tools/visualization/_text.py", line 394, in fillup_layer
    longest = max([len(name) for name in names])
ValueError: max() arg is an empty sequence
```

### What is the expected behavior?

No ValueError.

### Suggested solutions

Check whether `names` is empty or not. 



Discussion:

Resolving patch:
diff --git a/qiskit/tools/visualization/_text.py b/qiskit/tools/visualization/_text.py
--- a/qiskit/tools/visualization/_text.py
+++ b/qiskit/tools/visualization/_text.py
@@ -784,8 +784,11 @@ def build_layers(self):
         Raises:
             VisualizationError: When the drawing is, for some reason, impossible to be drawn.
         """
+        wire_names = self.wire_names(with_initial_value=True)
+        if not wire_names:
+            return []
 
-        layers = [InputWire.fillup_layer(self.wire_names(with_initial_value=True))]
+        layers = [InputWire.fillup_layer(wire_names)]
 
         for instruction_layer in self.instructions:
             layer = Layer(self.qregs, self.cregs)


Test patch:
diff --git a/test/python/tools/visualization/test_circuit_text_drawer.py b/test/python/tools/visualization/test_circuit_text_drawer.py
--- a/test/python/tools/visualization/test_circuit_text_drawer.py
+++ b/test/python/tools/visualization/test_circuit_text_drawer.py
@@ -54,6 +54,12 @@ def test_measure_from(self):
                     "└╥┘"]
         self.assertEqualElement(expected, element)
 
+    def test_text_empty(self):
+        """ The empty circuit."""
+        expected = ''
+        circuit = QuantumCircuit()
+        self.assertEqual(str(_text_circuit_drawer(circuit)), expected)
+
     def test_text_pager(self):
         """ The pager breaks the circuit when the drawing does not fit in the console."""
         expected = '\n'.join(["        ┌───┐     »",