Exemple #1
0
    def test_decollate_overlay_of_dmaps(self):
        overlay = Overlay([
            DynamicMap(lambda z: Points([z, z]), streams=[Z()]),
            DynamicMap(lambda z: Points([z, z]), streams=[Z()]),
            DynamicMap(lambda z: Points([z, z]), streams=[Z()]),
        ])

        decollated = overlay.decollate()
        self.assertIsInstance(decollated, DynamicMap)
        self.assertEqual(len(decollated.streams), 3)

        expected = Overlay(
            [Points([1.0, 1.0]),
             Points([2.0, 2.0]),
             Points([3.0, 3.0])])

        # Build result by updating streams
        decollated.streams[0].event(z=1.0)
        decollated.streams[1].event(z=2.0)
        decollated.streams[2].event(z=3.0)
        result = decollated[()]
        self.assertEqual(expected, result)

        # Build result by calling callback function
        result = decollated.callback.callable(dict(z=1.0), dict(z=2.0),
                                              dict(z=3.0))
        self.assertEqual(expected, result)
Exemple #2
0
 def test_interleaved_overlay(self):
     """
     Test to avoid regression after fix of https://github.com/holoviz/holoviews/issues/41
     """
     o = Overlay([
         Curve(np.array([[0, 1]])),
         Scatter([[1, 1]]),
         Curve(np.array([[0, 1]]))
     ])
     OverlayPlot(o)
 def test_holomap_legend_updates_varying_lengths(self):
     hmap = HoloMap({i: Overlay([Curve([1, 2, j], label=chr(65+j)) for j in range(i)]) for i in range(1, 4)})
     plot = bokeh_renderer.get_plot(hmap)
     legend_labels = [item.label for item in plot.state.legend[0].items]
     self.assertEqual(legend_labels, [{'value': 'A'}])
     plot.update((2,))
     legend_labels = [item.label for item in plot.state.legend[0].items]
     self.assertEqual(legend_labels, [{'value': 'A'}, {'value': 'B'}])
     plot.update((3,))
     legend_labels = [item.label for item in plot.state.legend[0].items]
     self.assertEqual(legend_labels, [{'value': 'A'}, {'value': 'B'}, {'value': 'C'}])
 def callback(items):
     return NdOverlay({j: Overlay([Curve([1, 2, j])]) for j in range(items)})
 def test_overlay_gridspace_collate(self):
     grid = GridSpace({(i, j): Curve(np.arange(10) * i)
                       for i in range(3) for j in range(3)})
     overlaid = Overlay([grid, grid, grid]).collate()
     self.assertEqual(overlaid, grid * grid * grid)
 def test_overlay_hmap_collate(self):
     hmap = HoloMap({i: Curve(np.arange(10) * i) for i in range(3)})
     overlaid = Overlay([hmap, hmap, hmap]).collate()
     self.assertEqual(overlaid, hmap * hmap * hmap)