Repository: Qiskit/qiskit

Issue:
can't draw a schedule 
after #3394 got merged, a simple `schedule.draw()` fails.

are there no tests for this?

```python
---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)
<ipython-input-5-5df9debb5295> in <module>
----> 1 cmd_def.get('u3', [0], 0.3, 0.6, 0.9).draw()

~/Desktop/ajavadia-terra/qiskit/pulse/schedule.py in draw(self, dt, style, filename, interp_method, scaling, channels_to_plot, plot_all, plot_range, interactive, table, label, framechange, channels)
    392                                           plot_range=plot_range, interactive=interactive,
    393                                           table=table, label=label,
--> 394                                           framechange=framechange, channels=channels)
    395 
    396     def __eq__(self, other: ScheduleComponent) -> bool:

~/Desktop/ajavadia-terra/qiskit/visualization/pulse_visualization.py in pulse_drawer(data, dt, style, filename, interp_method, scaling, channels_to_plot, plot_all, plot_range, interactive, table, label, framechange, channels)
     75         image = drawer.draw(data, dt=dt, interp_method=interp_method, scaling=scaling,
     76                             plot_range=plot_range, plot_all=plot_all, table=table,
---> 77                             label=label, framechange=framechange, channels=channels)
     78     else:
     79         raise VisualizationError('This data cannot be visualized.')

~/Desktop/ajavadia-terra/qiskit/visualization/pulse/matplotlib.py in draw(self, schedule, dt, interp_method, plot_range, scaling, channels_to_plot, plot_all, table, label, framechange, channels)
    601         # prepare waveform channels
    602         (schedule_channels, output_channels,
--> 603          snapshot_channels) = self._build_channels(schedule, channels_to_plot, t0, tf)
    604 
    605         # count numbers of valid waveform

~/Desktop/ajavadia-terra/qiskit/visualization/pulse/matplotlib.py in _build_channels(self, schedule, channels_to_plot, t0, tf)
    290         snapshot_channels = collections.OrderedDict()
    291 
--> 292         _channels = list(schedule.channels) + channels_to_plot
    293         _channels = list(set(_channels))
    294 

TypeError: can only concatenate list (not "NoneType") to list
```


Discussion:

Resolving patch:
diff --git a/qiskit/visualization/pulse/matplotlib.py b/qiskit/visualization/pulse/matplotlib.py
--- a/qiskit/visualization/pulse/matplotlib.py
+++ b/qiskit/visualization/pulse/matplotlib.py
@@ -281,7 +281,7 @@ def __init__(self, style):
         """
         self.style = style or SchedStyle()
 
-    def _build_channels(self, schedule, channels_to_plot, t0, tf):
+    def _build_channels(self, schedule, channels, t0, tf):
         # prepare waveform channels
         drive_channels = collections.OrderedDict()
         measure_channels = collections.OrderedDict()
@@ -289,7 +289,7 @@ def _build_channels(self, schedule, channels_to_plot, t0, tf):
         acquire_channels = collections.OrderedDict()
         snapshot_channels = collections.OrderedDict()
 
-        _channels = list(schedule.channels) + channels_to_plot
+        _channels = list(schedule.channels) + channels
         _channels = list(set(_channels))
 
         for chan in _channels:
@@ -574,12 +574,12 @@ def draw(self, schedule, dt, interp_method, plot_range,
         """
         figure = plt.figure()
 
-        if channels_to_plot:
+        if channels_to_plot is not None:
             warnings.warn('The parameter "channels_to_plot" is being replaced by "channels"',
                           DeprecationWarning, 3)
             channels = channels_to_plot
 
-        if not channels:
+        if channels is None:
             channels = []
         interp_method = interp_method or interpolation.step_wise
 
@@ -592,15 +592,15 @@ def draw(self, schedule, dt, interp_method, plot_range,
             # when input schedule is empty or comprises only frame changes,
             # we need to overwrite pulse duration by an integer greater than zero,
             # otherwise waveform returns empty array and matplotlib will be crashed.
-            if channels_to_plot:
-                tf = schedule.timeslots.ch_duration(*channels_to_plot)
+            if channels:
+                tf = schedule.timeslots.ch_duration(*channels)
             else:
                 tf = schedule.stop_time
             tf = tf or 1
 
         # prepare waveform channels
         (schedule_channels, output_channels,
-         snapshot_channels) = self._build_channels(schedule, channels_to_plot, t0, tf)
+         snapshot_channels) = self._build_channels(schedule, channels, t0, tf)
 
         # count numbers of valid waveform
         n_valid_waveform, v_max = self._count_valid_waveforms(output_channels, scaling=scaling,


Test patch:
diff --git a/test/python/visualization/references/instruction_matplotlib_ref.png b/test/python/visualization/references/instruction_matplotlib_ref.png
Binary files a/test/python/visualization/references/instruction_matplotlib_ref.png and b/test/python/visualization/references/instruction_matplotlib_ref.png differ
diff --git a/test/python/visualization/references/pulse_matplotlib_ref.png b/test/python/visualization/references/pulse_matplotlib_ref.png
Binary files a/test/python/visualization/references/pulse_matplotlib_ref.png and b/test/python/visualization/references/pulse_matplotlib_ref.png differ
diff --git a/test/python/visualization/references/schedule_matplotlib_ref.png b/test/python/visualization/references/schedule_matplotlib_ref.png
Binary files a/test/python/visualization/references/schedule_matplotlib_ref.png and b/test/python/visualization/references/schedule_matplotlib_ref.png differ