本文整理汇总了Python中holoviews.core.spaces.DynamicMap.collate方法的典型用法代码示例。如果您正苦于以下问题:Python DynamicMap.collate方法的具体用法?Python DynamicMap.collate怎么用?Python DynamicMap.collate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews.core.spaces.DynamicMap
的用法示例。
在下文中一共展示了DynamicMap.collate方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_dynamic_collate_layout_raise_ambiguous_remapping_error
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_layout_raise_ambiguous_remapping_error(self):
def callback(x, y):
return Image(np.array([[0, 1], [2, 3]])) + Image(np.array([[0, 1], [2, 3]]))
stream = PointerXY()
cb_callable = Callable(callback, stream_mapping={'Image': [stream]})
dmap = DynamicMap(cb_callable, kdims=[], streams=[stream])
with self.assertRaisesRegexp(ValueError, 'The stream_mapping supplied on the Callable is ambiguous'):
dmap.collate()
示例2: test_dynamic_collate_layout_raise_no_remapping_error
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_layout_raise_no_remapping_error(self):
def callback(x, y):
return Image(np.array([[0, 1], [2, 3]])) + Text(0, 0, 'Test')
stream = PointerXY()
cb_callable = Callable(callback)
dmap = DynamicMap(cb_callable, kdims=[], streams=[stream])
with self.assertRaisesRegexp(ValueError, 'The following streams are set to be automatically linked'):
dmap.collate()
示例3: test_dynamic_collate_ndlayout
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_ndlayout(self):
def callback():
return NdLayout({i: Image(np.array([[i, 1], [2, 3]])) for i in range(1, 3)})
dmap = DynamicMap(callback, kdims=[])
layout = dmap.collate()
self.assertEqual(list(layout.keys()), [1, 2])
self.assertEqual(layout[1][()], Image(np.array([[1, 1], [2, 3]])))
示例4: test_dynamic_collate_layout
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_layout(self):
def callback():
return Image(np.array([[0, 1], [2, 3]])) + Text(0, 0, 'Test')
dmap = DynamicMap(callback, kdims=[])
layout = dmap.collate()
self.assertEqual(list(layout.keys()), [('Image', 'I'), ('Text', 'I')])
self.assertEqual(layout.Image.I[()], Image(np.array([[0, 1], [2, 3]])))
示例5: test_dynamic_collate_layout_with_changing_label
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_layout_with_changing_label(self):
def callback(i):
return Layout([Curve([], label=str(j)) for j in range(i, i+2)])
dmap = DynamicMap(callback, kdims=['i']).redim.range(i=(0, 10))
layout = dmap.collate()
dmap1, dmap2 = layout.values()
el1, el2 = dmap1[2], dmap2[2]
self.assertEqual(el1.label, '2')
self.assertEqual(el2.label, '3')
示例6: test_dynamic_collate_grid
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_grid(self):
def callback():
return GridSpace({(i, j): Image(np.array([[i, j], [2, 3]]))
for i in range(1, 3) for j in range(1, 3)})
dmap = DynamicMap(callback, kdims=[])
grid = dmap.collate()
self.assertEqual(list(grid.keys()), [(i, j) for i in range(1, 3)
for j in range(1, 3)])
self.assertEqual(grid[(0, 1)][()], Image(np.array([[1, 1], [2, 3]])))
示例7: test_dynamic_collate_ndlayout_with_key_stream_mapping
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_ndlayout_with_key_stream_mapping(self):
def callback(x, y):
return NdLayout({i: Image(np.array([[i, 1], [2, 3]])) for i in range(1, 3)})
stream = PointerXY()
cb_callable = Callable(callback, stream_mapping={(1,): [stream]})
dmap = DynamicMap(cb_callable, kdims=[], streams=[stream])
layout = dmap.collate()
self.assertEqual(list(layout.keys()), [1, 2])
self.assertIs(stream.source, layout[1])
示例8: test_dynamic_collate_layout_with_spec_stream_mapping
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_layout_with_spec_stream_mapping(self):
def callback(x, y):
return Image(np.array([[0, 1], [2, 3]])) + Text(0, 0, 'Test')
stream = PointerXY()
cb_callable = Callable(callback, stream_mapping={'Image': [stream]})
dmap = DynamicMap(cb_callable, kdims=[], streams=[stream])
layout = dmap.collate()
self.assertEqual(list(layout.keys()), [('Image', 'I'), ('Text', 'I')])
self.assertIs(stream.source, layout.Image.I)
示例9: test_dynamic_collate_gridspace_with_changing_items_raises
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_gridspace_with_changing_items_raises(self):
def callback(i):
return GridSpace({j: Curve([], label=str(j)) for j in range(i)}, 'X')
dmap = DynamicMap(callback, kdims=['i']).redim.range(i=(2, 10))
layout = dmap.collate()
dmap1, dmap2 = layout.values()
err = 'Collated DynamicMaps must return GridSpace with consistent number of items.'
with self.assertRaisesRegexp(ValueError, err):
dmap1[4]
示例10: test_dynamic_collate_grid_with_key_stream_mapping
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_grid_with_key_stream_mapping(self):
def callback():
return GridSpace({(i, j): Image(np.array([[i, j], [2, 3]]))
for i in range(1, 3) for j in range(1, 3)})
stream = PointerXY()
cb_callable = Callable(callback, stream_mapping={(1, 2): [stream]})
dmap = DynamicMap(cb_callable, kdims=[])
grid = dmap.collate()
self.assertEqual(list(grid.keys()), [(i, j) for i in range(1, 3)
for j in range(1, 3)])
self.assertEqual(stream.source, grid[(1, 2)])
示例11: test_dynamic_collate_gridspace_with_changing_item_types_raises
# 需要导入模块: from holoviews.core.spaces import DynamicMap [as 别名]
# 或者: from holoviews.core.spaces.DynamicMap import collate [as 别名]
def test_dynamic_collate_gridspace_with_changing_item_types_raises(self):
def callback(i):
eltype = Image if i%2 else Curve
return GridSpace({j: eltype([], label=str(j)) for j in range(i, i+2)}, 'X')
dmap = DynamicMap(callback, kdims=['i']).redim.range(i=(2, 10))
layout = dmap.collate()
dmap1, dmap2 = layout.values()
err = ('The objects in a GridSpace returned by a DynamicMap must '
'consistently return the same number of items of the same type.')
with self.assertRaisesRegexp(ValueError, err):
dmap1[3]