def test_hline_layout(self): layout = (HLine(1) + HLine(2) + HLine(3) + HLine(4)).cols(2).opts(vspacing=0, hspacing=0) state = self._get_plot_state(layout) shapes = state['layout']['shapes'] self.assertEqual(len(shapes), 4) # Check shapes self.assert_hline(shapes[0], 3, yref='y', xdomain=[0.0, 0.5]) self.assert_hline(shapes[1], 4, yref='y2', xdomain=[0.5, 1.0]) self.assert_hline(shapes[2], 1, yref='y3', xdomain=[0.0, 0.5]) self.assert_hline(shapes[3], 2, yref='y4', xdomain=[0.5, 1.0])
def test_single_hline(self): hline = HLine(3) state = self._get_plot_state(hline) shapes = state['layout']['shapes'] self.assertEqual(len(shapes), 1) self.assert_hline(shapes[0], 3)
def test_gridspace_overlay_reverse(self): items = [(0, self.view1), (1, self.view2), (2, self.view3), (3, self.view2)] grid = GridSpace(items, 'X') hline = HLine(0) overlaid_grid = hline * grid expected = GridSpace([(k, hline*v) for k, v in items], 'X') self.assertEqual(overlaid_grid, expected)
def test_gridspace_overlay_element(self): items = [(0, self.view1), (1, self.view2), (2, self.view3), (3, self.view2)] grid = GridSpace(items, 'X') hline = HLine(0) overlaid_grid = grid * hline expected = GridSpace([(k, v*hline) for k, v in items], 'X') self.assertEqual(overlaid_grid, expected)
def test_ndlayout_overlay_reverse(self): items = [(0, self.view1), (1, self.view2), (2, self.view3), (3, self.view2)] grid = NdLayout(items) hline = HLine(0) overlaid_grid = hline * grid expected = NdLayout([(k, hline*v) for k, v in items]) self.assertEqual(overlaid_grid, expected)
def test_ndlayout_overlay_element(self): items = [(0, self.view1), (1, self.view2), (2, self.view3), (3, self.view2)] grid = NdLayout(items) hline = HLine(0) overlaid_grid = grid * hline expected = NdLayout([(k, v*hline) for k, v in items]) self.assertEqual(overlaid_grid, expected)
def setUp(self): self.dmap_element = DynamicMap(lambda: Image([])) self.dmap_overlay = DynamicMap(lambda: Overlay([Curve([]), Points([])])) self.dmap_ndoverlay = DynamicMap(lambda: NdOverlay({0: Curve([]), 1: Curve([])})) self.element = Scatter([]) self.el1, self.el2 = Path([]), HLine(0) self.overlay = Overlay([self.el1, self.el2]) self.ndoverlay = NdOverlay({0: VectorField([]), 1: VectorField([])})
def test_launch_server_with_complex_plot(self): dmap = DynamicMap(lambda x_range, y_range: Curve([]), streams=[RangeXY()]) overlay = dmap * HLine(0) static = Polygons([]) * Path([]) * Curve([]) layout = overlay + static _, server = self._launcher(layout) server.stop()
def test_overlay_categorical_two_level(self): bars = Bars([('A', 'a', 1), ('B', 'b', 2), ('A', 'b', 3), ('B', 'a', 4)], kdims=['Upper', 'Lower']) plot = bokeh_renderer.get_plot(bars * HLine(2)) x_range = plot.handles['x_range'] assert isinstance(x_range, FactorRange) assert x_range.factors == [('A', 'a'), ('A', 'b'), ('B', 'a'), ('B', 'b')] assert isinstance(plot.state.renderers[-1], Span)
def test_launch_server_with_complex_plot(self): dmap = DynamicMap(lambda x_range, y_range: Curve([]), streams=[RangeXY()]) overlay = dmap * HLine(0) static = Polygons([]) * Path([]) * Curve([]) layout = overlay + static launched = [] def modify_doc(doc): bokeh_renderer(layout, doc=doc) launched.append(True) server.stop() handler = FunctionHandler(modify_doc) app = Application(handler) server = Server({'/': app}, port=0) server.start() url = "http://localhost:" + str(server.port) + "/" pull_session(session_id='Test', url=url, io_loop=server.io_loop) self.assertTrue(len(launched)==1)
def test_hline_invert_axes(self): hline = HLine(1.1).opts(plot=dict(invert_axes=True)) plot = bokeh_renderer.get_plot(hline) span = plot.handles['glyph'] self.assertEqual(span.dimension, 'height') self.assertEqual(span.location, 1.1)
def test_hline_plot(self): hline = HLine(1.1) plot = bokeh_renderer.get_plot(hline) span = plot.handles['glyph'] self.assertEqual(span.dimension, 'width') self.assertEqual(span.location, 1.1)
def crosshair(time): return VLine(time) * HLine(time)
def test_hline_styling(self): self.assert_shape_element_styling(HLine(3))