Beispiel #1
0
 def test_bars_positive_negative_mixed(self):
     bars = Bars([('A', 0, 1), ('A', 1, -1), ('B', 0, 2)],
                 kdims=['Index', 'Category'], vdims=['Value'])
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(stack_index=1)))
     source = plot.handles['source']
     self.assertEqual(list(source.data['Category']), ['1', '0', '0'])
     self.assertEqual(list(source.data['Index']), ['A', 'A', 'B'])
     self.assertEqual(source.data['top'], np.array([0, 1, 2]))
     self.assertEqual(source.data['bottom'], np.array([-1, 0, 0]))
Beispiel #2
0
 def test_bars_positive_negative_mixed(self):
     bars = Bars([('A', 0, 1), ('A', 1, -1), ('B', 0, 2)],
                 kdims=['Index', 'Category'], vdims=['Value'])
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(stack_index=1)))
     source = plot.handles['source']
     self.assertEqual(list(source.data['Category']), ['1', '0', '0'])
     self.assertEqual(list(source.data['Index']), ['A', 'A', 'B'])
     self.assertEqual(source.data['top'], np.array([0, 1, 2]))
     self.assertEqual(source.data['bottom'], np.array([-1, 0, 0]))
Beispiel #3
0
 def test_bars_logy_explicit_range(self):
     bars = Bars([('A', 1), ('B', 2), ('C', 3)],
                 kdims=['Index'], vdims=['Value']).redim.range(Value=(0.001, 3))
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(logy=True)))
     source = plot.handles['source']
     glyph = plot.handles['glyph']
     y_range = plot.handles['y_range']
     self.assertEqual(list(source.data['Index']), ['A', 'B', 'C'])
     self.assertEqual(source.data['Value'], np.array([1, 2, 3]))
     self.assertEqual(glyph.bottom, 0.001)
     self.assertEqual(y_range.start, 0.001)
     self.assertEqual(y_range.end, 3.)
Beispiel #4
0
 def test_bars_logy_explicit_range(self):
     bars = Bars([('A', 1), ('B', 2), ('C', 3)],
                 kdims=['Index'], vdims=['Value']).redim.range(Value=(0.001, 3))
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(logy=True)))
     source = plot.handles['source']
     glyph = plot.handles['glyph']
     y_range = plot.handles['y_range']
     self.assertEqual(list(source.data['Index']), ['A', 'B', 'C'])
     self.assertEqual(source.data['Value'], np.array([1, 2, 3]))
     self.assertEqual(glyph.bottom, 0.001)
     self.assertEqual(y_range.start, 0.001)
     self.assertEqual(y_range.end, 3.0000000000000013)
Beispiel #5
0
 def test_bars_logy(self):
     bars = Bars([('A', 1), ('B', 2), ('C', 3)],
                 kdims=['Index'], vdims=['Value'])
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(logy=True)))
     source = plot.handles['source']
     glyph = plot.handles['glyph']
     y_range = plot.handles['y_range']
     self.assertEqual(list(source.data['Index']), ['A', 'B', 'C'])
     self.assertEqual(source.data['Value'], np.array([1, 2, 3]))
     self.assertEqual(glyph.bottom, 10**(np.log10(3)-2))
     self.assertEqual(y_range.start, 10**(np.log10(3)-2))
     self.assertEqual(y_range.end, 3.)
Beispiel #6
0
 def test_bars_logy(self):
     bars = Bars([('A', 1), ('B', 2), ('C', 3)],
                 kdims=['Index'],
                 vdims=['Value'])
     plot = bokeh_renderer.get_plot(bars.opts(plot=dict(logy=True)))
     source = plot.handles['source']
     glyph = plot.handles['glyph']
     y_range = plot.handles['y_range']
     self.assertEqual(list(source.data['Index']), ['A', 'B', 'C'])
     self.assertEqual(source.data['Value'], np.array([1, 2, 3]))
     self.assertEqual(glyph.bottom, 10**(np.log10(3) - 2))
     self.assertEqual(y_range.start, 0.03348369522101712)
     self.assertEqual(y_range.end, 3.348369522101713)
Beispiel #7
0
 def test_bars_hover_ensure_vdims_sanitized(self):
     obj = Bars(np.random.rand(10, 2), vdims=['Dim with spaces'])
     obj = obj.opts(tools=['hover'])
     self._test_hover_info(obj, [('x', '@{x}'),
                                 ('Dim with spaces', '@{Dim_with_spaces}')])