本文整理汇总了Python中holoviews.core.spaces.DynamicMap类的典型用法代码示例。如果您正苦于以下问题:Python DynamicMap类的具体用法?Python DynamicMap怎么用?Python DynamicMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了DynamicMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_redim_dimension_values_cache_reset_1D
def test_redim_dimension_values_cache_reset_1D(self):
# Setting the values should drop mismatching keys from the cache
fn = lambda i: Curve([i,i])
dmap = DynamicMap(fn, kdims=['i'])[{0,1,2,3,4,5}]
self.assertEqual(dmap.keys(), [0,1,2,3,4,5])
redimmed = dmap.redim.values(i=[2,3,5,6,8])
self.assertEqual(redimmed.keys(), [2,3,5])
示例2: test_dynamic_collate_layout
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]])))
示例3: test_dynamic_collate_ndlayout
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_deep_apply_transform_element_type
def test_deep_apply_transform_element_type(self):
fn = lambda i: Curve(np.arange(i))
dmap = DynamicMap(fn, kdims=[Dimension('Test', range=(10, 20))])
dmap[10]
mapped = dmap.apply(lambda x: Scatter(x))
area = mapped[11]
self.assertEqual(area, Scatter(fn(11)))
示例5: test_dynamic_collate_layout_raise_no_remapping_error
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()
示例6: test_dynamic_event_renaming_valid
def test_dynamic_event_renaming_valid(self):
def fn(x1, y1):
return Scatter([(x1, y1)])
xy = PointerXY(rename={'x':'x1','y':'y1'})
dmap = DynamicMap(fn, kdims=[], streams=[xy])
dmap.event(x1=1, y1=2)
示例7: test_dynamic_collate_layout_raise_ambiguous_remapping_error
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()
示例8: test_dynamic_split_overlays_on_ndoverlay
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]))
示例9: test_periodic_param_fn_blocking
def test_periodic_param_fn_blocking(self):
def callback(x): return Curve([1,2,3])
xval = Stream.define('x',x=0)()
dmap = DynamicMap(callback, streams=[xval])
# Add stream subscriber mocking plot
xval.add_subscriber(lambda **kwargs: dmap[()])
dmap.periodic(0.01, 100, param_fn=lambda i: {'x':i})
self.assertEqual(xval.x, 100)
示例10: test_dynamic_reindex_reorder
def test_dynamic_reindex_reorder(self):
def history_callback(x, y, history=deque(maxlen=10)):
history.append((x, y))
return Points(list(history))
dmap = DynamicMap(history_callback, kdims=['x', 'y'])
reindexed = dmap.reindex(['y', 'x'])
points = reindexed[2, 1]
self.assertEqual(points, Points([(1, 2)]))
示例11: test_redim_dimension_values_cache_reset_2D_multi
def test_redim_dimension_values_cache_reset_2D_multi(self):
# Setting the values should drop mismatching keys from the cache
fn = lambda i,j: Curve([i,j])
keys = [(0,1),(1,0),(2,2),(2,5), (3,3)]
dmap = DynamicMap(fn, kdims=['i','j'])[keys]
self.assertEqual(dmap.keys(), keys)
redimmed = dmap.redim.values(i=[2,10,50], j=[5,50,100])
self.assertEqual(redimmed.keys(), [(2,5)])
示例12: test_dynamic_collate_layout_with_changing_label
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')
示例13: test_dynamic_collate_layout_with_spec_stream_mapping
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)
示例14: test_dynamic_collate_ndlayout_with_key_stream_mapping
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])
示例15: test_dynamic_reindex_drop_raises_exception
def test_dynamic_reindex_drop_raises_exception(self):
def history_callback(x, y, history=deque(maxlen=10)):
history.append((x, y))
return Points(list(history))
dmap = DynamicMap(history_callback, kdims=['x', 'y'])
exception = ("DynamicMap does not allow dropping dimensions, "
"reindex may only be used to reorder dimensions.")
with self.assertRaisesRegexp(ValueError, exception):
dmap.reindex(['x'])