Repository: holoviz/holoviews (Python)

Issue:
Regression with Sankey plot
#### ALL software version info
Holoviews: 0.13.1
Python: 3.7
Bokeh: 2.0

#### Description of expected behavior and the observed behavior
Regression with a sankey plot case that was working in 0.12

Case now leads to a ZeroDivisionError.

#### Complete, minimal, self-contained example code that reproduces the issue

```
empty = pd.DataFrame({'source':['No data'], 'target':[' No data'], 'count':[1]})
sankey = hv.Sankey(empty)

```

#### Stack traceback and/or browser JavaScript console output
    215             max_depth = max(depths.values()) - 1 if depths else 1
    216             height = self.p.bounds[3] - self.p.bounds[1]
--> 217             py = min((height * 0.1) / max_depth, 20)
    218 
    219         def initializeNodeBreadth():

ZeroDivisionError: float division by zero
#### Screenshots or screencasts of the bug in action

Expected result which is given by 0.12.7:
![image](https://user-images.githubusercontent.com/7702207/77818990-a6fb7b80-70d7-11ea-9fe0-1bea78059fc3.png)



Discussion:
This issue has been automatically locked since there has not been any recent activity after it was closed. Please open a new issue for related bugs.



Patch:
diff --git a/holoviews/element/sankey.py b/holoviews/element/sankey.py
index 2c1f6f8d95..653d622e15 100644
--- a/holoviews/element/sankey.py
+++ b/holoviews/element/sankey.py
@@ -214,7 +214,7 @@ def computeNodeBreadths(self, graph):
         if py is None:
             max_depth = max(depths.values()) - 1 if depths else 1
             height = self.p.bounds[3] - self.p.bounds[1]
-            py = min((height * 0.1) / max_depth, 20)
+            py = min((height * 0.1) / max_depth, 20) if max_depth else 20
 
         def initializeNodeBreadth():
             kys = []


Test patch:
diff --git a/holoviews/tests/element/testgraphelement.py b/holoviews/tests/element/testgraphelement.py
index a0b48ed896..90309cb40b 100644
--- a/holoviews/tests/element/testgraphelement.py
+++ b/holoviews/tests/element/testgraphelement.py
@@ -11,6 +11,7 @@
 from holoviews.element.graphs import (
     Graph, Nodes, TriMesh, Chord, circular_layout, connect_edges,
     connect_edges_pd)
+from holoviews.element.sankey import Sankey
 from holoviews.element.comparison import ComparisonTestCase
 
 pd_skip = skipIf(util.pd is None, 'Pandas not available')
@@ -294,3 +295,43 @@ def test_trimesh_edgepaths(self):
     def test_trimesh_select(self):
         trimesh = TriMesh((self.simplices, self.nodes)).select(x=(0.1, None))
         self.assertEqual(trimesh.array(), np.array(self.simplices[1:]))
+
+
+class TestSankey(ComparisonTestCase):
+
+    def test_single_edge_sankey(self):
+        sankey = Sankey([('A', 'B', 1)])
+        links = list(sankey._sankey['links'])
+        self.assertEqual(len(links), 1)
+        del links[0]['source']['sourceLinks']
+        del links[0]['target']['targetLinks']
+        link = {
+            'index': 0,
+            'source': {
+                'index': 'A',
+                'values': (),
+                'targetLinks': [],
+                'value': 1,
+                'depth': 0,
+                'height': 1,
+                'x0': 0,
+                'x1': 15,
+                'y0': 0.0,
+                'y1': 500.0},
+            'target': {
+                'index': 'B',
+                'values': (),
+                'sourceLinks': [],
+                'value': 1,
+                'depth': 1,
+                'height': 0,
+                'x0': 985.0,
+                'x1': 1000.0,
+                'y0': 0.0,
+                'y1': 500.0},
+            'value': 1,
+            'width': 500.0,
+            'y0': 0.0,
+            'y1': 0.0
+        }
+        self.assertEqual(links[0], link)