From 4cf953fce58e73a8beaf8f9122acfc7b1d62e152 Mon Sep 17 00:00:00 2001 From: Philipp Rudiger Date: Tue, 13 Feb 2018 12:36:56 +0000 Subject: [PATCH] Fixed bokeh graph plot test --- holoviews/core/data/dictionary.py | 2 +- holoviews/core/util.py | 5 ++++- holoviews/plotting/bokeh/graphs.py | 1 + tests/testbokehgraphs.py | 2 +- 4 files changed, 7 insertions(+), 3 deletions(-) diff --git a/holoviews/core/data/dictionary.py b/holoviews/core/data/dictionary.py index 28cc115b0a..f965e204c1 100644 --- a/holoviews/core/data/dictionary.py +++ b/holoviews/core/data/dictionary.py @@ -217,7 +217,7 @@ def values(cls, dataset, dim, expanded=True, flat=True): else: if not expanded: return util.unique_array(values) - values = np.array(values) + values = np.asarray(values) return values diff --git a/holoviews/core/util.py b/holoviews/core/util.py index b539d15497..973689c7e2 100644 --- a/holoviews/core/util.py +++ b/holoviews/core/util.py @@ -838,7 +838,10 @@ def unique_array(arr): if not len(arr): return arr elif pd: - return pd.unique(arr) + unique = pd.unique(arr) + if isinstance(arr, np.ndarray) and unique.dtype != arr.dtype: + return unique.astype(arr.dtype) + return unique else: arr = np.asarray(arr) _, uniq_inds = np.unique(arr, return_index=True) diff --git a/holoviews/plotting/bokeh/graphs.py b/holoviews/plotting/bokeh/graphs.py index f340666f61..3803ef565a 100644 --- a/holoviews/plotting/bokeh/graphs.py +++ b/holoviews/plotting/bokeh/graphs.py @@ -93,6 +93,7 @@ def _get_edge_colors(self, element, ranges, edge_data, edge_mapping, style): field = dimension_sanitizer(cdim.name) cvals = element.dimension_values(cdim) if idx in self._node_columns: + print(element.nodes.interface) factors = element.nodes.dimension_values(2, expanded=False) elif idx == 2 and cvals.dtype.kind in 'if': factors = None diff --git a/tests/testbokehgraphs.py b/tests/testbokehgraphs.py index 7a2ed25a5d..00ff9ca0b3 100644 --- a/tests/testbokehgraphs.py +++ b/tests/testbokehgraphs.py @@ -34,7 +34,7 @@ def setUp(self): self.weights = np.random.rand(N) self.graph = Graph(((self.source, self.target),)) self.node_info = Dataset(['Output']+['Input']*(N-1), vdims=['Label']) - self.node_info2 = Dataset(self.weights, vdims='Weight') + self.node_info2 = Dataset(self.weights, vdims='Weight', datatype=['dictionary']) self.graph2 = Graph(((self.source, self.target), self.node_info)) self.graph3 = Graph(((self.source, self.target), self.node_info2), datatype=['dictionary']) self.graph4 = Graph(((self.source, self.target, self.weights),), vdims='Weight')