Skip to content

Commit

Permalink
Added double trailing underscores to categorized columns in CDS
Browse files Browse the repository at this point in the history
  • Loading branch information
philippjfr committed Oct 10, 2018
1 parent ae814ed commit 52cd6fa
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 9 deletions.
4 changes: 2 additions & 2 deletions holoviews/plotting/bokeh/element.py
Original file line number Diff line number Diff line change
Expand Up @@ -1186,14 +1186,14 @@ def _get_color_data(self, element, ranges, style, name='color', factors=None, co
if factors is None and (isinstance(cdata, list) or cdata.dtype.kind in dtypes):
factors = list(util.unique_array(cdata))
if factors and int_categories and cdata.dtype.kind == 'i':
field += '_str'
field += '_str__'
cdata = [str(f) for f in cdata]
factors = [str(f) for f in factors]

mapper = self._get_colormapper(cdim, element, ranges, style,
factors, colors)
if not factors and isinstance(mapper, CategoricalColorMapper):
field += '_str'
field += '_str__'
cdata = [cdim.pprint_value(c) for c in cdata]
factors = mapper.factors

Expand Down
2 changes: 1 addition & 1 deletion holoviews/tests/plotting/bokeh/testelementplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -241,7 +241,7 @@ def test_explicit_categorical_cmap_on_integer_data(self):
plot = bokeh_renderer.get_plot(points)
cmapper = plot.handles['color_mapper']
cds = plot.handles['cds']
self.assertEqual(cds.data['Category_str'], ['0', '1', '2', '3'])
self.assertEqual(cds.data['Category_str__'], ['0', '1', '2', '3'])
self.assertEqual(cmapper.factors, ['0', '1', '2', '3'])
self.assertEqual(cmapper.palette, ['blue', 'red', 'green', 'purple'])

Expand Down
12 changes: 6 additions & 6 deletions holoviews/tests/plotting/bokeh/testgraphplot.py
Original file line number Diff line number Diff line change
Expand Up @@ -142,8 +142,8 @@ def test_graph_edges_categorical_colormapped(self):
self.assertIsInstance(cmapper, CategoricalColorMapper)
factors = ['0', '1', '2', '3', '4', '5', '6', '7']
self.assertEqual(cmapper.factors, factors)
self.assertEqual(edge_source.data['start_str'], factors)
self.assertEqual(glyph.line_color, {'field': 'start_str', 'transform': cmapper})
self.assertEqual(edge_source.data['start_str__'], factors)
self.assertEqual(glyph.line_color, {'field': 'start_str__', 'transform': cmapper})

def test_graph_edges_numerically_colormapped(self):
g = self.graph4.opts(plot=dict(edge_color_index='Weight'),
Expand Down Expand Up @@ -202,8 +202,8 @@ def test_graph_edges_categorical_colormapped(self):
self.assertIsInstance(cmapper, CategoricalColorMapper)
factors = ['0', '1', '2', '3']
self.assertEqual(cmapper.factors, factors)
self.assertEqual(edge_source.data['node1_str'], ['0', '1'])
self.assertEqual(glyph.line_color, {'field': 'node1_str', 'transform': cmapper})
self.assertEqual(edge_source.data['node1_str__'], ['0', '1'])
self.assertEqual(glyph.line_color, {'field': 'node1_str__', 'transform': cmapper})

def test_graph_nodes_numerically_colormapped(self):
g = self.trimesh_weighted.opts(plot=dict(edge_color_index='weight'),
Expand Down Expand Up @@ -258,6 +258,6 @@ def test_chord_edges_categorically_colormapped(self):
self.assertIsInstance(cmapper, CategoricalColorMapper)
self.assertEqual(cmapper.palette, ['#FFFFFF', '#000000', '#FFFFFF'])
self.assertEqual(cmapper.factors, ['0', '1', '2'])
self.assertEqual(edge_source.data['start_str'], ['0', '0', '1'])
self.assertEqual(glyph.line_color, {'field': 'start_str', 'transform': cmapper})
self.assertEqual(edge_source.data['start_str__'], ['0', '0', '1'])
self.assertEqual(glyph.line_color, {'field': 'start_str__', 'transform': cmapper})

0 comments on commit 52cd6fa

Please sign in to comment.