本文整理汇总了Python中holoviews.Curve方法的典型用法代码示例。如果您正苦于以下问题:Python holoviews.Curve方法的具体用法?Python holoviews.Curve怎么用?Python holoviews.Curve使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews
的用法示例。
在下文中一共展示了holoviews.Curve方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_render_dynamicmap_with_stream_dims
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_render_dynamicmap_with_stream_dims(self):
stream = Stream.define(str('Custom'), y=2)()
dmap = DynamicMap(lambda x, y: Curve([x, 1, y]), kdims=['x', 'y'],
streams=[stream]).redim.values(x=[1, 2, 3])
obj, _ = self.renderer._validate(dmap, None)
self.renderer.components(obj)
[(plot, pane)] = obj._plots.values()
cds = plot.handles['cds']
self.assertEqual(cds.data['y'][2], 2)
stream.event(y=3)
self.assertEqual(cds.data['y'][2], 3)
self.assertEqual(cds.data['y'][0], 1)
slider = obj.layout.select(DiscreteSlider)[0]
slider.value = 3
self.assertEqual(cds.data['y'][0], 3)
示例2: test_to_element
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_to_element(self):
curve = self.ds.to(Curve, 'a', 'b', groupby=[])
curve2 = self.ds2.to(Curve, 'a', 'b', groupby=[])
self.assertNotEqual(curve, curve2)
self.assertEqual(curve.dataset, self.ds)
scatter = curve.to(Scatter)
self.assertEqual(scatter.dataset, self.ds)
# Check pipeline
ops = curve.pipeline.operations
self.assertEqual(len(ops), 2)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
# Execute pipeline
self.assertEqual(curve.pipeline(curve.dataset), curve)
self.assertEqual(
curve.pipeline(self.ds2), curve2
)
示例3: test_to_holomap_dask
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_to_holomap_dask(self):
if dd is None:
raise SkipTest("Dask required to test .to with dask dataframe.")
ddf = dd.from_pandas(self.df, npartitions=2)
dds = Dataset(
ddf,
kdims=[
Dimension('a', label="The a Column"),
Dimension('b', label="The b Column"),
Dimension('c', label="The c Column"),
Dimension('d', label="The d Column"),
]
)
curve_hmap = dds.to(Curve, 'a', 'b', groupby=['c'])
# Check HoloMap element datasets
for v in self.df.c.drop_duplicates():
curve = curve_hmap.data[(v,)]
self.assertEqual(
curve.dataset, self.ds
)
# Execute pipeline
self.assertEqual(curve.pipeline(curve.dataset), curve)
示例4: test_reindex_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_reindex_curve(self):
curve_ba = self.ds.to(
Curve, 'a', 'b', groupby=[]
).reindex(kdims='b', vdims='a')
curve2_ba = self.ds2.to(
Curve, 'a', 'b', groupby=[]
).reindex(kdims='b', vdims='a')
self.assertNotEqual(curve_ba, curve2_ba)
self.assertEqual(curve_ba.dataset, self.ds)
# Check pipeline
ops = curve_ba.pipeline.operations
self.assertEqual(len(ops), 3)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertEqual(ops[2].method_name, 'reindex')
self.assertEqual(ops[2].args, [])
self.assertEqual(ops[2].kwargs, dict(kdims='b', vdims='a'))
# Execute pipeline
self.assertEqual(curve_ba.pipeline(curve_ba.dataset), curve_ba)
self.assertEqual(
curve_ba.pipeline(self.ds2), curve2_ba
)
示例5: test_iloc_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_iloc_curve(self):
# Curve
curve_iloc = self.ds.to.curve('a', 'b', groupby=[]).iloc[[0, 2]]
curve2_iloc = self.ds2.to.curve('a', 'b', groupby=[]).iloc[[0, 2]]
self.assertNotEqual(curve_iloc, curve2_iloc)
self.assertEqual(
curve_iloc.dataset,
self.ds
)
# Check pipeline
ops = curve_iloc.pipeline.operations
self.assertEqual(len(ops), 3)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertEqual(ops[2].method_name, '_perform_getitem')
self.assertEqual(ops[2].args, [[0, 2]])
self.assertEqual(ops[2].kwargs, {})
# Execute pipeline
self.assertEqual(curve_iloc.pipeline(curve_iloc.dataset), curve_iloc)
self.assertEqual(
curve_iloc.pipeline(self.ds2), curve2_iloc
)
示例6: test_rasterize_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_rasterize_curve(self):
img = rasterize(
self.ds.to(Curve, 'a', 'b', groupby=[]), dynamic=False
)
img2 = rasterize(
self.ds2.to(Curve, 'a', 'b', groupby=[]), dynamic=False
)
self.assertNotEqual(img, img2)
# Check dataset
self.assertEqual(img.dataset, self.ds)
# Check pipeline
ops = img.pipeline.operations
self.assertEqual(len(ops), 3)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertIsInstance(ops[2], rasterize)
# Execute pipeline
self.assertEqual(img.pipeline(img.dataset), img)
self.assertEqual(img.pipeline(self.ds2), img2)
示例7: test_datashade_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_datashade_curve(self):
rgb = dynspread(datashade(
self.ds.to(Curve, 'a', 'b', groupby=[]), dynamic=False
), dynamic=False)
rgb2 = dynspread(datashade(
self.ds2.to(Curve, 'a', 'b', groupby=[]), dynamic=False
), dynamic=False)
self.assertNotEqual(rgb, rgb2)
# Check dataset
self.assertEqual(rgb.dataset, self.ds)
# Check pipeline
ops = rgb.pipeline.operations
self.assertEqual(len(ops), 4)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertIsInstance(ops[2], datashade)
self.assertIsInstance(ops[3], dynspread)
# Execute pipeline
self.assertEqual(rgb.pipeline(rgb.dataset), rgb)
self.assertEqual(rgb.pipeline(self.ds2), rgb2)
示例8: test_apply_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_apply_curve(self):
curve = self.ds.to.curve('a', 'b', groupby=[]).apply(
lambda c: Scatter(c.select(b=(20, None)).data)
)
curve2 = self.ds2.to.curve('a', 'b', groupby=[]).apply(
lambda c: Scatter(c.select(b=(20, None)).data)
)
self.assertNotEqual(curve, curve2)
# Check pipeline
ops = curve.pipeline.operations
self.assertEqual(len(ops), 4)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertIs(ops[2].output_type, Apply)
self.assertEqual(ops[2].kwargs, {'mode': None})
self.assertEqual(ops[3].method_name, '__call__')
# Execute pipeline
self.assertEqual(curve.pipeline(curve.dataset), curve)
self.assertEqual(
curve.pipeline(self.ds2), curve2
)
示例9: test_redim_curve
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_redim_curve(self):
curve = self.ds.to.curve('a', 'b', groupby=[]).redim.unit(
a='kg', b='m'
)
curve2 = self.ds2.to.curve('a', 'b', groupby=[]).redim.unit(
a='kg', b='m'
)
self.assertNotEqual(curve, curve2)
# Check pipeline
ops = curve.pipeline.operations
self.assertEqual(len(ops), 4)
self.assertIs(ops[0].output_type, Dataset)
self.assertIs(ops[1].output_type, Curve)
self.assertIs(ops[2].output_type, Redim)
self.assertEqual(ops[2].kwargs, {'mode': 'dataset'})
self.assertEqual(ops[3].method_name, '__call__')
# Execute pipeline
self.assertEqual(curve.pipeline(curve.dataset), curve)
self.assertEqual(
curve.pipeline(self.ds2), curve2
)
示例10: test_builder_backend_switch
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_builder_backend_switch(self):
if sys.version_info.major == 3:
raise SkipTest('Python 3 tab completes via __signature__ not __doc__')
Store.options(val=self.store_mpl, backend='matplotlib')
Store.options(val=self.store_bokeh, backend='bokeh')
Store.set_current_backend('bokeh')
self.assertEqual(opts.Curve.__doc__.startswith('Curve('), True)
docline = opts.Curve.__doc__.splitlines()[0]
dockeys = eval(docline.replace('Curve', 'dict'))
self.assertEqual('color' in dockeys, True)
self.assertEqual('line_width' in dockeys, True)
Store.set_current_backend('matplotlib')
self.assertEqual(opts.Curve.__doc__.startswith('Curve('), True)
docline = opts.Curve.__doc__.splitlines()[0]
dockeys = eval(docline.replace('Curve', 'dict'))
self.assertEqual('color' in dockeys, True)
self.assertEqual('linewidth' in dockeys, True)
示例11: test_mpl_bokeh_mpl_via_builders_opts_method_literal_implicit_backend
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_mpl_bokeh_mpl_via_builders_opts_method_literal_implicit_backend(self):
img = Image(np.random.rand(10,10))
curve = Curve([1,2,3])
overlay = img * curve
Store.set_current_backend('matplotlib')
literal = {'Curve':
{'style':dict(color='orange')},
'Image':
{'style':dict(cmap='jet'), 'output':dict(backend='bokeh')}
}
styled = overlay.opts(literal)
mpl_curve_lookup = Store.lookup_options('matplotlib', styled.Curve.I, 'style')
self.assertEqual(mpl_curve_lookup.kwargs['color'], 'orange')
mpl_img_lookup = Store.lookup_options('matplotlib', styled.Image.I, 'style')
self.assertNotEqual(mpl_img_lookup.kwargs['cmap'], 'jet')
bokeh_curve_lookup = Store.lookup_options('bokeh', styled.Curve.I, 'style')
self.assertNotEqual(bokeh_curve_lookup.kwargs['color'], 'orange')
bokeh_img_lookup = Store.lookup_options('bokeh', styled.Image.I, 'style')
self.assertEqual(bokeh_img_lookup.kwargs['cmap'], 'jet')
示例12: test_mpl_bokeh_mpl_via_builders_opts_method_flat_literal_explicit_backend
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_mpl_bokeh_mpl_via_builders_opts_method_flat_literal_explicit_backend(self):
img = Image(np.random.rand(10,10))
curve = Curve([1,2,3])
overlay = img * curve
Store.set_current_backend('matplotlib')
literal = {'Curve': dict(color='orange', backend='matplotlib'),
'Image': dict(cmap='jet', backend='bokeh')
}
styled = overlay.opts(literal)
mpl_curve_lookup = Store.lookup_options('matplotlib', styled.Curve.I, 'style')
self.assertEqual(mpl_curve_lookup.kwargs['color'], 'orange')
mpl_img_lookup = Store.lookup_options('matplotlib', styled.Image.I, 'style')
self.assertNotEqual(mpl_img_lookup.kwargs['cmap'], 'jet')
bokeh_curve_lookup = Store.lookup_options('bokeh', styled.Curve.I, 'style')
self.assertNotEqual(bokeh_curve_lookup.kwargs['color'], 'orange')
bokeh_img_lookup = Store.lookup_options('bokeh', styled.Image.I, 'style')
self.assertEqual(bokeh_img_lookup.kwargs['cmap'], 'jet')
示例13: test_mpl_bokeh_output_options_group_expandable
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_mpl_bokeh_output_options_group_expandable(self):
original_allowed_kws = Options._output_allowed_kws[:]
Options._output_allowed_kws = ['backend', 'file_format_example']
# Re-register
Store.register({Curve: plotting.mpl.CurvePlot}, 'matplotlib')
Store.register({Curve: plotting.bokeh.CurvePlot}, 'bokeh')
curve_bk = Options('Curve', backend='bokeh', color='blue')
curve_mpl = Options('Curve', backend='matplotlib', color='red',
file_format_example='SVG')
c = Curve([1,2,3])
styled = c.opts(curve_bk, curve_mpl)
self.assertEqual(Store.lookup_options('matplotlib', styled, 'output').kwargs,
{'backend':'matplotlib', 'file_format_example':'SVG'})
self.assertEqual(Store.lookup_options('bokeh', styled, 'output').kwargs,
{})
Options._output_allowed_kws = original_allowed_kws
示例14: test_overlay_options_partitioned
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_overlay_options_partitioned(self):
"""
The new style introduced in #73
"""
data = [zip(range(10),range(10)), zip(range(5),range(5))]
o = Overlay([Curve(c) for c in data]).opts(
dict(plot={'Curve.Curve':{'show_grid':False}},
style={'Curve.Curve':{'color':'k'}}))
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.I, 'plot').kwargs['show_grid'], False)
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.II, 'plot').kwargs['show_grid'], False)
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.I, 'style').kwargs['color'], 'k')
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.II, 'style').kwargs['color'], 'k')
示例15: test_overlay_options_complete
# 需要导入模块: import holoviews [as 别名]
# 或者: from holoviews import Curve [as 别名]
def test_overlay_options_complete(self):
"""
Complete specification style.
"""
data = [zip(range(10),range(10)), zip(range(5),range(5))]
o = Overlay([Curve(c) for c in data]).opts(
{'Curve.Curve':{'plot':{'show_grid':True},
'style':{'color':'b'}}})
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.I, 'plot').kwargs['show_grid'], True)
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.II, 'plot').kwargs['show_grid'], True)
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.I, 'style').kwargs['color'], 'b')
self.assertEqual(Store.lookup_options('matplotlib',
o.Curve.II, 'style').kwargs['color'], 'b')