示例#1
0
 def test_contours_categorical_color_op(self):
     contours = Contours([{
         ('x', 'y'): [(0, 0), (0, 1), (1, 0)],
         'color': 'b'
     }, {
         ('x', 'y'): [(1, 0), (1, 1), (0, 1)],
         'color': 'a'
     }],
                         vdims='color').options(color='color')
     plot = bokeh_renderer.get_plot(contours)
     cds = plot.handles['source']
     glyph = plot.handles['glyph']
     cmapper = plot.handles['color_color_mapper']
     self.assertEqual(glyph.line_color, {
         'field': 'color',
         'transform': cmapper
     })
     self.assertEqual(cds.data['color'], np.array(['b', 'a']))
     self.assertIsInstance(cmapper, CategoricalColorMapper)
     self.assertEqual(cmapper.factors, ['b', 'a'])
示例#2
0
    def setUp(self):
        self.img_fn = lambda: Image(np.random.rand(10, 10))
        self.contour_fn = lambda: Contours([np.random.rand(10, 2)
                                            for i in range(2)])
        params = [list(range(3)) for i in range(2)]
        self.sanitized_map = HoloMap({i: Image(i*np.random.rand(10,10))
                                      for i in range(1,10)}, kdims=['A B'])
        self.img_map = HoloMap({(i, j): self.img_fn()
                                for i, j in product(*params)},
                               kdims=['a', 'b'])
        self.contour_map = HoloMap({(i, j): self.contour_fn()
                                    for i, j in product(*params)},
                                   kdims=['a', 'b'])
        self.ndoverlay_map = self.img_map.overlay('b')
        self.overlay_map = self.img_map * self.contour_map
        self.layout_map = self.ndoverlay_map + self.contour_map
        self.duplicate_map = self.img_map.clone(kdims=['x', 'y'])

        self.overlap1 = HoloMap({i: self.img_fn() for i in range(5)})
        self.overlap2 = HoloMap({i: self.img_fn() for i in range(10)})
        self.overlap_layout = self.overlap1 + self.overlap2
 def test_contours_linear_color_op(self):
     contours = Contours([{
         ('x', 'y'): [(0, 0), (0, 1), (1, 0)],
         'color': 7
     }, {
         ('x', 'y'): [(1, 0), (1, 1), (0, 1)],
         'color': 3
     }],
                         vdims='color').options(color='color')
     plot = bokeh_renderer.get_plot(contours)
     cds = plot.handles['source']
     glyph = plot.handles['glyph']
     cmapper = plot.handles['color_color_mapper']
     self.assertEqual(glyph.line_color, {
         'field': 'color',
         'transform': cmapper
     })
     self.assertEqual(cds.data['color'], np.array([7, 3]))
     self.assertIsInstance(cmapper, LinearColorMapper)
     self.assertEqual(cmapper.low, 3)
     self.assertEqual(cmapper.high, 7)