Ejemplo n.º 1
0
 def test(x):
     return Points([x])
Ejemplo n.º 2
0
 def test_get_min_distance_int32_type(self):
     xs, ys = (np.arange(0, 10, dtype='int32'),
               np.arange(0, 10, dtype='int32'))
     X, Y = np.meshgrid(xs, ys)
     dist = get_min_distance(Points((X.flatten(), Y.flatten())))
     self.assertEqual(dist, 1.0)
Ejemplo n.º 3
0
 def test_point_draw_callback_initialized_server(self):
     points = Points([(0, 1)])
     PointDraw(source=points)
     plot = bokeh_server_renderer.get_plot(points)
     self.assertEqual(plot.handles['source']._callbacks,
                      {'data': [plot.callbacks[0].on_change]})
Ejemplo n.º 4
0
 def test_array_points_iloc_index_rows(self):
     arrays = [np.array([(1+i, i), (2+i, i), (3+i, i)]) for i in range(2)]
     mds = Points(arrays, kdims=['x', 'y'], datatype=[self.datatype])
     self.assertIs(mds.interface, self.interface)
     self.assertEqual(mds.iloc[[1, 3, 4]], Points([(2, 0), (2, 1), (3, 1)], ['x', 'y']))
Ejemplo n.º 5
0
 def test_array_length_points(self):
     arrays = [np.column_stack([np.arange(i, i+2), np.arange(i, i+2)]) for i in range(2)]
     mds = Points(arrays, kdims=['x', 'y'], datatype=[self.datatype])
     self.assertIs(mds.interface, self.interface)
     self.assertEqual(len(mds), 4)
Ejemplo n.º 6
0
 def test_layout_disable_toolbar(self):
     layout = (Curve([]) + Points([])).options(toolbar=None)
     plot = bokeh_renderer.get_plot(layout)
     self.assertIsInstance(plot.state, GridBox)
     self.assertEqual(len(plot.state.children), 2)
Ejemplo n.º 7
0
 def history_callback(x, y, history=deque(maxlen=10)):
     history.append((x, y))
     return Points(list(history))
 def test_point_constructor(self):
     points = Points([{'x': 0, 'y': 1}, {'x': 1, 'y': 0}], ['x', 'y'],
                     datatype=[self.datatype])
     self.assertIsInstance(points.data.geometry.dtype, PointDtype)
     self.assertEqual(points.data.iloc[0, 0].flat_values, np.array([0, 1]))
     self.assertEqual(points.data.iloc[1, 0].flat_values, np.array([1, 0]))
Ejemplo n.º 9
0
 def test_source_registry(self):
     points = Points([(0, 0)])
     positionX = PointerX(source=points)
     self.assertIn(id(points), Stream.registry)
Ejemplo n.º 10
0
 def test_source_registry(self):
     points = Points([(0, 0)])
     PointerX(source=points)
     self.assertIn(points, Stream.registry)
Ejemplo n.º 11
0
 def test_source_registry_empty_element(self):
     points = Points([])
     PointerX(source=points)
     self.assertIn(points, Stream.registry)
Ejemplo n.º 12
0
 def test_source_empty_dmap(self):
     points_dmap = DynamicMap(lambda x: Points([]), kdims=['X'])
     stream = PointerX(source=points_dmap)
     self.assertIs(stream.source, points_dmap)
Ejemplo n.º 13
0
 def test_source_empty_element(self):
     points = Points([])
     stream = PointerX(source=points)
     self.assertIs(stream.source, points)
Ejemplo n.º 14
0
 def points(data):
     subscriber.call_count += 1
     return Points([(0, data)])
Ejemplo n.º 15
0
 def test_points_rcparams_do_not_persist(self):
     opts = dict(fig_rcparams={'text.usetex': True})
     points = Points(([0, 1], [0, 3])).opts(plot=opts)
     mpl_renderer.get_plot(points)
     self.assertFalse(pyplot.rcParams['text.usetex'])
Ejemplo n.º 16
0
 def test_source_registry_empty_element(self):
     points = Points([])
     positionX = PointerX(source=points)
     self.assertIn(id(points), Stream.registry)
Ejemplo n.º 17
0
 def test_layout_set_toolbar_location(self):
     layout = (Curve([]) + Points([])).options(toolbar='left')
     plot = bokeh_renderer.get_plot(layout)
     self.assertIsInstance(plot.state, Row)
     self.assertIsInstance(plot.state.children[0], ToolbarBox)
Ejemplo n.º 18
0
 def test_point_size_op(self):
     points = Points([(0, 0, 1), (0, 1, 4), (0, 2, 8)],
                     vdims='size').options(s='size')
     plot = mpl_renderer.get_plot(points)
     artist = plot.handles['artist']
     self.assertEqual(artist.get_sizes(), np.array([1, 4, 8]))
Ejemplo n.º 19
0
 def cb(i):
     if i % 2 == 0:
         return Curve([]) * Points([])
     else:
         return Scatter([]) * Curve([])
Ejemplo n.º 20
0
 def test_point_line_width_op(self):
     points = Points([(0, 0, 1), (0, 1, 4), (0, 2, 8)],
                     vdims='line_width').options(linewidth='line_width')
     plot = mpl_renderer.get_plot(points)
     artist = plot.handles['artist']
     self.assertEqual(artist.get_linewidths(), [1, 4, 8])
Ejemplo n.º 21
0
 def test_array_points_iloc_slice_rows_no_stop(self):
     arrays = [np.array([(1+i, i), (2+i, i), (3+i, i)]) for i in range(2)]
     mds = Points(arrays, kdims=['x', 'y'], datatype=[self.datatype])
     self.assertIs(mds.interface, self.interface)
     self.assertEqual(mds.iloc[2:], Points([(3, 0), (2, 1), (3, 1), (4, 1)], ['x', 'y']))
Ejemplo n.º 22
0
 def test_point_marker_op(self):
     points = Points([(0, 0, 'circle'), (0, 1, 'triangle'), (0, 2, 'square')],
                     vdims='marker').options(marker='marker')
     with self.assertRaises(Exception):
         mpl_renderer.get_plot(points)
Ejemplo n.º 23
0
 def test_array_points_iloc_index_rows_index_cols(self):
     arrays = [np.array([(1+i, i), (2+i, i), (3+i, i)]) for i in range(2)]
     mds = Points(arrays, kdims=['x', 'y'], datatype=[self.datatype])
     self.assertIs(mds.interface, self.interface)
     self.assertEqual(mds.iloc[3, 0], 2)
     self.assertEqual(mds.iloc[3, 1], 1)
Ejemplo n.º 24
0
 def test_point_alpha_op(self):
     points = Points([(0, 0, 0), (0, 1, 0.2), (0, 2, 0.7)],
                     vdims='alpha').options(alpha='alpha')
     with self.assertRaises(Exception):
         mpl_renderer.get_plot(points)
Ejemplo n.º 25
0
 def test_get_min_distance_float32_type(self):
     xs, ys = (np.arange(0, 2., .2, dtype='float32'),
               np.arange(0, 2., .2, dtype='float32'))
     X, Y = np.meshgrid(xs, ys)
     dist = get_min_distance(Points((X.flatten(), Y.flatten())))
     self.assertEqual(round(dist, 5), 0.2)
Ejemplo n.º 26
0
 def test_points_cbar_extend_max(self):
     img = Points(([0, 1], [0, 3])).redim(y=dict(range=(None, 2)))
     plot = mpl_renderer.get_plot(img.opts(colorbar=True, color_index=1))
     self.assertEqual(plot.handles['cbar'].extend, 'max')
Ejemplo n.º 27
0
 def test_selection1d_syncs_to_selected(self):
     points = Points([(0, 0), (1, 1), (2, 2)]).opts(selected=[0, 2])
     stream = Selection1D(source=points)
     bokeh_renderer.get_plot(points)
     self.assertEqual(stream.index, [0, 2])
Ejemplo n.º 28
0
 def test_points_cbar_extend_clime(self):
     img = Points(([0, 1], [0, 3])).opts(style=dict(clim=(None, None)))
     plot = mpl_renderer.get_plot(img.opts(colorbar=True, color_index=1))
     self.assertEqual(plot.handles['cbar'].extend, 'neither')
Ejemplo n.º 29
0
 def test_point_draw_callback_with_vdims_initialization(self):
     points = Points([(0, 1, 'A')], vdims=['A'])
     stream = PointDraw(source=points)
     bokeh_server_renderer.get_plot(points)
     self.assertEqual(stream.element.dimension_values('A'), np.array(['A']))
Ejemplo n.º 30
0
 def action_number_method(self):
     self.count += 1
     return Points([])