def test_vspan_invert_axes(self): vspan = VSpan(1.1, 1.5).opts(invert_axes=True) plot = bokeh_renderer.get_plot(vspan) span = plot.handles['glyph'] self.assertEqual(span.left, None) self.assertEqual(span.right, None) self.assertEqual(span.bottom, 1.1) self.assertEqual(span.top, 1.5)
def test_vspan_plot(self): vspan = VSpan(1.1, 1.5) plot = bokeh_renderer.get_plot(vspan) span = plot.handles['glyph'] self.assertEqual(span.left, 1.1) self.assertEqual(span.right, 1.5) self.assertEqual(span.bottom, None) self.assertEqual(span.top, None)
def test_curve_selection_categorical(self): curve = Curve((['B', 'A', 'C', 'D', 'E'], [3, 2, 1, 3, 4])) expr, bbox, region = curve._get_selection_expr_for_stream_value( bounds=(0, 1, 2, 3), x_selection=['B', 'A', 'C'] ) self.assertEqual(bbox, {'x': ['B', 'A', 'C']}) self.assertEqual(expr.apply(curve), np.array([True, True, True, False, False])) self.assertEqual(region, NdOverlay({0: VSpan(0, 2)}))
def test_curve_selection_numeric(self): curve = Curve([3, 2, 1, 3, 4]) expr, bbox, region = curve._get_selection_expr_for_stream_value( bounds=(1, 0, 3, 2)) self.assertEqual(bbox, {'x': (1, 3)}) self.assertEqual(expr.apply(curve), np.array([False, True, True, True, False])) self.assertEqual(region, NdOverlay({0: VSpan(1, 3)}))
def test_distribution_single(self): dist = Distribution(list(range(10))) expr, bbox, region = dist._get_selection_expr_for_stream_value( bounds=(3, 0, 7, 1) ) self.assertEqual(bbox, {'Value': (3, 7)}) self.assertEqual(expr.apply(dist), np.array([ False, False, False, True, True, True, True, True, False, False ])) self.assertEqual(region, NdOverlay({0: VSpan(3, 7)}))
def test_violin_single_inverted(self): violin = Violin(list(range(10))).opts(invert_axes=True) expr, bbox, region = violin._get_selection_expr_for_stream_value( bounds=(3, 0, 7, 1) ) self.assertEqual(bbox, {'y': (3, 7)}) self.assertEqual(expr.apply(violin), np.array([ False, False, False, True, True, True, True, True, False, False ])) self.assertEqual(region, NdOverlay({0: VSpan(3, 7)}))
def test_box_whisker_single_inverted(self): box = BoxWhisker(list(range(10))).opts(invert_axes=True) expr, bbox, region = box._get_selection_expr_for_stream_value( bounds=(3, 0, 7, 1) ) self.assertEqual(bbox, {'y': (3, 7)}) self.assertEqual(expr.apply(box), np.array([ False, False, False, True, True, True, True, True, False, False ])) self.assertEqual(region, NdOverlay({0: VSpan(3, 7)}))