Repository: holoviz/panel

Issue:
When layout initialized with empty list plotly error
```python
pn.Column([])
```
```python-traceback
---------------------------------------------------------------------------
ModuleNotFoundError                       Traceback (most recent call last)
<ipython-input-100-8bd431d8f26d> in <module>
----> 1 pn.Column([])

~/panel/panel/layout.py in __init__(self, *objects, **params)
     33     def __init__(self, *objects, **params):
     34         from .pane import panel
---> 35         objects = [panel(pane) for pane in objects]
     36         super(Panel, self).__init__(objects=objects, **params)
     37 

~/panel/panel/layout.py in <listcomp>(.0)
     33     def __init__(self, *objects, **params):
     34         from .pane import panel
---> 35         objects = [panel(pane) for pane in objects]
     36         super(Panel, self).__init__(objects=objects, **params)
     37 

~/panel/panel/pane.py in panel(obj, **kwargs)
     45     if kwargs.get('name', False) is None:
     46         kwargs.pop('name')
---> 47     pane = PaneBase.get_pane_type(obj)(obj, **kwargs)
     48     if len(pane.layout) == 1 and pane._unpack:
     49         return pane.layout[0]

~/panel/panel/plotly.py in __init__(self, object, layout, **params)
     41 
     42     def __init__(self, object, layout=None, **params):
---> 43         super(Plotly, self).__init__(self._to_figure(object, layout),
     44                                      plotly_layout=layout, **params)
     45 

~/panel/panel/plotly.py in _to_figure(self, obj, layout)
     50 
     51     def _to_figure(self, obj, layout={}):
---> 52         import plotly.graph_objs as go
     53         if isinstance(obj, go.Figure):
     54             fig = obj

ModuleNotFoundError: No module named 'plotly'
```


Discussion:

Resolving patch:
diff --git a/panel/layout.py b/panel/layout.py
--- a/panel/layout.py
+++ b/panel/layout.py
@@ -356,7 +356,7 @@ def append(self, pane):
         new_objects = list(self)
         new_objects.append(panel(pane, name=name))
         name = param_name(new_objects[-1].name) if name is None else name
-        self._names[-1] = name
+        self._names.append(name)
         self.objects = new_objects
 
     def insert(self, index, pane):
diff --git a/panel/plotly.py b/panel/plotly.py
--- a/panel/plotly.py
+++ b/panel/plotly.py
@@ -45,7 +45,7 @@ def __init__(self, object, layout=None, **params):
 
     @classmethod
     def applies(cls, obj):
-        return ((isinstance(obj, list) and all(cls.applies(o) for o in obj)) or
+        return ((isinstance(obj, list) and obj and all(cls.applies(o) for o in obj)) or
                 hasattr(obj, 'to_plotly_json'))
 
     def _to_figure(self, obj, layout={}):


Test patch:
diff --git a/panel/tests/test_layout.py b/panel/tests/test_layout.py
--- a/panel/tests/test_layout.py
+++ b/panel/tests/test_layout.py
@@ -332,6 +332,17 @@ def test_tabs_append(document, comm):
     tab1, tab2, tab3 = model.tabs
 
 
+def test_empty_tabs_append(document, comm):
+    tabs = Tabs()
+
+    model = tabs._get_root(document, comm=comm)
+
+    div1 = Div()
+    tabs.append(('test title', div1))
+    assert len(model.tabs) == 1
+    assert model.tabs[0].title == 'test title'
+
+
 def test_tabs_insert(document, comm):
     div1 = Div()
     div2 = Div()
diff --git a/panel/tests/test_param.py b/panel/tests/test_param.py
--- a/panel/tests/test_param.py
+++ b/panel/tests/test_param.py
@@ -530,9 +530,9 @@ class Test(param.Parameterized):
 
 def test_expand_param_subobject_tabs(document, comm):
     class Test(param.Parameterized):
-        a = param.Parameter()
+        abc = param.Parameter()
 
-    test = Test(a=Test(name='Nested'), name='A')
+    test = Test(abc=Test(name='Nested'), name='A')
     test_pane = Pane(test, expand_layout=Tabs, _temporary=True)
     model = test_pane._get_root(document, comm=comm)
 
@@ -540,11 +540,11 @@ class Test(param.Parameterized):
     assert isinstance(toggle, Toggle)
 
     # Expand subpanel
-    test_pane._widgets['a'][1].value = True
+    test_pane._widgets['abc'][1].value = True
     assert len(model.tabs) == 2
     _, subpanel = test_pane.layout.objects
     subtabs = model.tabs[1].child
-    assert model.tabs[1].title == 'Nested'
+    assert model.tabs[1].title == 'Abc'
     assert 'instance' in subpanel._callbacks
     assert isinstance(subtabs, BkTabs)
     assert len(subtabs.tabs) == 1
@@ -557,7 +557,7 @@ class Test(param.Parameterized):
     assert isinstance(widget, BkTextInput)
 
     # Collapse subpanel
-    test_pane._widgets['a'][1].value = False
+    test_pane._widgets['abc'][1].value = False
     assert len(model.tabs) == 1
     assert subpanel._callbacks == {}