當前位置: 首頁>>代碼示例>>Python>>正文


Python holoviews.Curve方法代碼示例

本文整理匯總了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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:19,代碼來源:testrenderer.py

示例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
        ) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:23,代碼來源:testdatasetproperty.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:27,代碼來源:testdatasetproperty.py

示例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
        ) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:27,代碼來源:testdatasetproperty.py

示例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
        ) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:27,代碼來源:testdatasetproperty.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:24,代碼來源:testdatasetproperty.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:25,代碼來源:testdatasetproperty.py

示例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
        ) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:25,代碼來源:testdatasetproperty.py

示例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
        ) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:26,代碼來源:testdatasetproperty.py

示例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) 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:19,代碼來源:testoptions.py

示例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') 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:25,代碼來源:testoptions.py

示例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') 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:23,代碼來源:testoptions.py

示例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 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:20,代碼來源:testoptions.py

示例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') 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:19,代碼來源:teststoreoptions.py

示例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') 
開發者ID:holoviz,項目名稱:holoviews,代碼行數:19,代碼來源:teststoreoptions.py


注:本文中的holoviews.Curve方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。