def test_dynamic_split_overlays_on_ndoverlay(self): dmap = DynamicMap(lambda: NdOverlay({i: Points([i]) for i in range(3)})) initialize_dynamic(dmap) keys, dmaps = dmap._split_overlays() self.assertEqual(keys, [(0,), (1,), (2,)]) self.assertEqual(dmaps[0][()], Points([0])) self.assertEqual(dmaps[1][()], Points([1])) self.assertEqual(dmaps[2][()], Points([2]))
def test_dynamic_split_overlays_on_varying_order_overlay(self): def cb(i): if i%2 == 0: return Curve([]) * Points([]) else: return Points([]) * Curve([]) dmap = DynamicMap(cb, kdims='i').redim.range(i=(0, 4)) initialize_dynamic(dmap) keys, dmaps = dmap._split_overlays() self.assertEqual(keys, [('Curve', 'I'), ('Points', 'I')]) self.assertEqual(dmaps[0][0], Curve([])) self.assertEqual(dmaps[0][1], Curve([])) self.assertEqual(dmaps[1][0], Points([])) self.assertEqual(dmaps[1][1], Points([]))
def test_dynamic_split_overlays_on_missing_item_in_overlay(self): def cb(i): if i%2 == 0: return Curve([]) * Points([]) else: return Scatter([]) * Curve([]) dmap = DynamicMap(cb, kdims='i').redim.range(i=(0, 4)) initialize_dynamic(dmap) keys, dmaps = dmap._split_overlays() self.assertEqual(keys, [('Curve', 'I'), ('Points', 'I')]) self.assertEqual(dmaps[0][0], Curve([])) self.assertEqual(dmaps[0][1], Curve([])) self.assertEqual(dmaps[1][0], Points([])) with self.assertRaises(KeyError): dmaps[1][1]