当前位置: 首页>>代码示例>>Python>>正文


Python holoviews.Store类代码示例

本文整理汇总了Python中holoviews.Store的典型用法代码示例。如果您正苦于以下问题:Python Store类的具体用法?Python Store怎么用?Python Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。


在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: test_custom_magic_to_default_inheritance

    def test_custom_magic_to_default_inheritance(self):
        """
        Checks customs inheritance backs off to default tree correctly
        simulating the %%opts cell magic.
        """
        if 'matplotlib' not in Store.renderers:
            raise SkipTest("Custom magic inheritance test requires matplotlib")
        options = self.initialize_option_tree()
        options.Image.A.B = Options('style', alpha=0.2)

        obj = Image(np.random.rand(10, 10), group='A', label='B')

        # Before customizing...
        expected_obj =  {'alpha': 0.2, 'cmap': 'hot', 'interpolation': 'nearest'}
        obj_lookup = Store.lookup_options('matplotlib', obj, 'style')
        self.assertEqual(obj_lookup.kwargs, expected_obj)

        custom_tree = {0: OptionTree(groups=['plot', 'style', 'norm'],
                                     style={'Image' : dict(clims=(0, 0.5))})}
        Store._custom_options['matplotlib'] = custom_tree
        obj.id = 0 # Manually set the id to point to the tree above

        # Customize this particular object
        expected_custom_obj =  dict(clims=(0,0.5), **expected_obj)
        custom_obj_lookup = Store.lookup_options('matplotlib', obj, 'style')
        self.assertEqual(custom_obj_lookup.kwargs, expected_custom_obj)
开发者ID:mforbes,项目名称:holoviews,代码行数:26,代码来源:testoptions.py

示例2: test_mpl_bokeh_offset_mpl

 def test_mpl_bokeh_offset_mpl(self):
     img = Image(np.random.rand(10,10))
     # Use blue in matplotlib
     Store.current_backend = 'matplotlib'
     StoreOptions.set_options(img, style={'Image':{'cmap':'Blues'}})
     mpl_opts = Store.lookup_options('matplotlib', img, 'style').options
     self.assertEqual(mpl_opts, {'cmap':'Blues'})
     # Switch to bokeh and style a random object...
     Store.current_backend = 'bokeh'
     img2 = Image(np.random.rand(10,10))
     StoreOptions.set_options(img2, style={'Image':{'cmap':'Reds'}})
     img2_opts = Store.lookup_options('bokeh', img2, 'style').options
     self.assertEqual(img2_opts, {'cmap':'Reds'})
     # Use purple in bokeh on the object...
     StoreOptions.set_options(img, style={'Image':{'cmap':'Purple'}})
     bokeh_opts = Store.lookup_options('bokeh', img, 'style').options
     self.assertEqual(bokeh_opts, {'cmap':'Purple'})
     # Check it is still blue in matplotlib...
     Store.current_backend = 'matplotlib'
     mpl_opts = Store.lookup_options('matplotlib', img, 'style').options
     self.assertEqual(mpl_opts, {'cmap':'Blues'})
     # And purple in bokeh..
     Store.current_backend = 'bokeh'
     bokeh_opts = Store.lookup_options('bokeh', img, 'style').options
     self.assertEqual(bokeh_opts, {'cmap':'Purple'})
     return img
开发者ID:mforbes,项目名称:holoviews,代码行数:26,代码来源:testoptions.py

示例3: setUp

 def setUp(self):
     if 'matplotlib' not in Store.renderers:
         raise SkipTest('Matplotlib backend not available.')
     self.store_copy = OptionTree(sorted(Store.options().items()),
                                  groups=Options._option_groups)
     self.backend = 'matplotlib'
     Store.set_current_backend(self.backend)
     super(TestOptsMethod, self).setUp()
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testoptions.py

示例4: test_style_transfer

 def test_style_transfer(self):
     hist = self.hist.opts(style={'style1':'style_child'})
     hist2 = self.hist.opts()
     opts = Store.lookup_options('matplotlib', hist2, 'style').kwargs
     self.assertEqual(opts, {'style1': 'style1', 'style2': 'style2'})
     Store.transfer_options(hist, hist2, 'matplotlib')
     opts = Store.lookup_options('matplotlib', hist2, 'style').kwargs
     self.assertEqual(opts, {'style1': 'style_child', 'style2': 'style2'})
开发者ID:mforbes,项目名称:holoviews,代码行数:8,代码来源:testoptions.py

示例5: test_style_inheritance_addition

 def test_style_inheritance_addition(self):
     "Adding an element"
     hist2 = self.hist(style={"style3": "style3"})
     self.assertEqual(
         Store.lookup_options(hist2, "style").options, dict(style1="style1", style2="style2", style3="style3")
     )
     # Check plot options works as expected
     self.assertEqual(Store.lookup_options(hist2, "plot").options, self.default_plot)
开发者ID:marwan116,项目名称:holoviews,代码行数:8,代码来源:testoptions.py

示例6: test_mpl_bokeh_mpl_via_dict_backend_keyword

 def test_mpl_bokeh_mpl_via_dict_backend_keyword(self):
     curve = Curve([1,2,3])
     styled_mpl = curve.opts({'Curve': dict(color='red')}, backend='matplotlib')
     styled = styled_mpl.opts({'Curve': dict(color='green')}, backend='bokeh')
     mpl_lookup = Store.lookup_options('matplotlib', styled, 'style')
     self.assertEqual(mpl_lookup.kwargs['color'], 'red')
     bokeh_lookup = Store.lookup_options('bokeh', styled, 'style')
     self.assertEqual(bokeh_lookup.kwargs['color'], 'green')
开发者ID:basnijholt,项目名称:holoviews,代码行数:8,代码来源:testoptions.py

示例7: setUp

    def setUp(self):

        if 'bokeh' not in Store.renderers:
            raise SkipTest("Cross background tests assumes bokeh is available.")
        self.store_mpl = OptionTree(sorted(Store.options(backend='matplotlib').items()),
                                    groups=['style', 'plot', 'norm'])
        self.store_bokeh = OptionTree(sorted(Store.options(backend='bokeh').items()),
                                    groups=['style', 'plot', 'norm'])
        self.clear_options()
        super(TestCrossBackendOptions, self).setUp()
开发者ID:mforbes,项目名称:holoviews,代码行数:10,代码来源:testoptions.py

示例8: tearDown

    def tearDown(self):
        Store.options(val=self.store_mpl, backend='matplotlib')
        Store.options(val=self.store_bokeh, backend='bokeh')
        Store.current_backend = 'matplotlib'
        Store._custom_options = {k:{} for k in Store._custom_options.keys()}

        if self.plotly_options is not None:
            Store._options['plotly'] = self.plotly_options

        super(TestCrossBackendOptionSpecification, self).tearDown()
开发者ID:basnijholt,项目名称:holoviews,代码行数:10,代码来源:testoptions.py

示例9: test_style_transfer

    def test_style_transfer(self):
        if 'matplotlib' not in Store.renderers:
            raise SkipTest("test_style_transfer requires matplotlib")

        hist = self.hist.opts(style={'style1':'style_child'})
        hist2 = self.hist.opts()
        opts = Store.lookup_options('matplotlib', hist2, 'style').kwargs
        self.assertEqual(opts, {'style1': 'style1', 'style2': 'style2'})
        Store.transfer_options(hist, hist2, 'matplotlib')
        opts = Store.lookup_options('matplotlib', hist2, 'style').kwargs
        self.assertEqual(opts, {'style1': 'style_child', 'style2': 'style2'})
开发者ID:basnijholt,项目名称:holoviews,代码行数:11,代码来源:testoptions.py

示例10: test_mpl_bokeh_mpl_via_builders_opts_method

 def test_mpl_bokeh_mpl_via_builders_opts_method(self):
     img = Image(np.random.rand(10,10))
     mpl_opts = opts.Image(cmap='Blues', backend='matplotlib')
     bokeh_opts = opts.Image(cmap='Purple', backend='bokeh')
     self.assertEqual(mpl_opts.kwargs['backend'], 'matplotlib')
     self.assertEqual(bokeh_opts.kwargs['backend'], 'bokeh')
     img.opts(mpl_opts, bokeh_opts)
     mpl_lookup = Store.lookup_options('matplotlib', img, 'style').options
     self.assertEqual(mpl_lookup['cmap'], 'Blues')
     bokeh_lookup = Store.lookup_options('bokeh', img, 'style').options
     self.assertEqual(bokeh_lookup['cmap'], 'Purple')
     self.assert_output_options_group_empty(img)
开发者ID:basnijholt,项目名称:holoviews,代码行数:12,代码来源:testoptions.py

示例11: clear_options

 def clear_options(self):
     # Clear global options..
     Store.options(val=OptionTree(groups=['plot', 'style']), backend='matplotlib')
     Store.options(val=OptionTree(groups=['plot', 'style']), backend='bokeh')
     # ... and custom options
     Store.custom_options({}, backend='matplotlib')
     Store.custom_options({}, backend='bokeh')
开发者ID:mforbes,项目名称:holoviews,代码行数:7,代码来源:testoptions.py

示例12: test_builder_cross_backend_validation

    def test_builder_cross_backend_validation(self):
        Store.options(val=self.store_mpl, backend='matplotlib')
        Store.options(val=self.store_bokeh, backend='bokeh')
        Store.set_current_backend('bokeh')
        opts.Curve(line_dash='dotted') # Bokeh keyword
        opts.Curve(linewidth=10)       # MPL keyword
        err = ("In opts.Curve\(...\),  keywords supplied are mixed across backends. "
               "Keyword\(s\) 'linewidth' are invalid for bokeh, "
               "'line_dash' are invalid for matplotlib")
        with self.assertRaisesRegexp(ValueError, err):
            opts.Curve(linewidth=10, line_dash='dotted') # Bokeh and MPL

        # Non-existent keyword across backends (bokeh active)
        err = ("In opts.Curve\(...\), unexpected option 'foobar' for Curve type "
               "across all extensions. Similar options for current "
               "extension \('bokeh'\) are: \['toolbar'\].")
        with self.assertRaisesRegexp(ValueError, err):
            opts.Curve(foobar=3)

        # Non-existent keyword across backends (matplotlib active)
        Store.set_current_backend('matplotlib')

        err = ("In opts.Curve\(...\), unexpected option 'foobar' for Curve "
               "type across all extensions. No similar options found.")
        with self.assertRaisesRegexp(ValueError, err):
            opts.Curve(foobar=3)
开发者ID:basnijholt,项目名称:holoviews,代码行数:26,代码来源:testoptions.py

示例13: test_specification_general_to_specific_group_and_label

    def test_specification_general_to_specific_group_and_label(self):
        """
        Test order of specification starting with general and moving
        to specific
        """
        if 'matplotlib' not in Store.renderers:
            raise SkipTest("General to specific option test requires matplotlib")

        options = self.initialize_option_tree()

        obj = Image(np.random.rand(10,10), group='SomeGroup', label='SomeLabel')

        options.Image = Options('style', cmap='viridis')
        options.Image.SomeGroup.SomeLabel = Options('style', alpha=0.2)

        expected = {'alpha': 0.2, 'cmap': 'viridis', 'interpolation': 'nearest'}
        lookup = Store.lookup_options('matplotlib', obj, 'style')

        self.assertEqual(lookup.kwargs, expected)
        # Check the tree is structured as expected
        node1 = options.Image.groups['style']
        node2 = options.Image.SomeGroup.SomeLabel.groups['style']

        self.assertEqual(node1.kwargs, {'cmap': 'viridis', 'interpolation': 'nearest'})
        self.assertEqual(node2.kwargs, {'alpha': 0.2})
开发者ID:mforbes,项目名称:holoviews,代码行数:25,代码来源:testoptions.py

示例14: init_notebook

def init_notebook(mpl=True):
    # Enable inline plotting in the notebook
    if mpl:
        try:
            get_ipython().enable_matplotlib(gui='inline')
        except NameError:
            pass

    print('Populated the namespace with:\n' +
        ', '.join(init_mooc_nb) +
        '\nfrom code/edx_components:\n' +
        ', '.join(edx_components.__all__) +
        '\nfrom code/functions:\n' +
        ', '.join(functions.__all__))

    holoviews.notebook_extension('matplotlib')

    Store.renderers['matplotlib'].fig = 'svg'

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.usetex'] = True
    
    latex_packs = [r'\usepackage{amsmath}',
                   r'\usepackage{amssymb}'
                   r'\usepackage{bm}']

    holoviews.plotting.mpl.MPLPlot.fig_rcparams['text.latex.preamble'] = latex_packs

    # Set plot style.
    options = Store.options(backend='matplotlib')
    options.Contours = Options('style', linewidth=2, color='k')
    options.Contours = Options('plot', aspect='square')
    options.HLine = Options('style', linestyle='--', color='b', linewidth=2)
    options.VLine = Options('style', linestyle='--', color='r', linewidth=2)
    options.Image = Options('style', cmap='RdBu_r')
    options.Image = Options('plot', title_format='{label}')
    options.Path = Options('style', linewidth=1.2, color='k')
    options.Path = Options('plot', aspect='square', title_format='{label}')
    options.Curve = Options('style', linewidth=2, color='k')
    options.Curve = Options('plot', aspect='square', title_format='{label}')
    options.Overlay = Options('plot', show_legend=False, title_format='{label}')
    options.Layout = Options('plot', title_format='{label}')
    options.Surface = Options('style', cmap='RdBu_r', rstride=1, cstride=1, lw=0.2)
    options.Surface = Options('plot', azimuth=20, elevation=8)

    # Turn off a bogus holoviews warning.
    # Temporary solution to ignore the warnings
    warnings.filterwarnings('ignore', r'All-NaN (slice|axis) encountered')

    module_dir = os.path.dirname(__file__)
    matplotlib.rc_file(os.path.join(module_dir, "matplotlibrc"))

    np.set_printoptions(precision=2, suppress=True,
                        formatter={'complexfloat': pretty_fmt_complex})

    # Patch a bug in holoviews
    if holoviews.__version__.release <= (1, 4, 3):
        from patch_holoviews import patch_all
        patch_all()
开发者ID:LionSR,项目名称:topocm_content,代码行数:58,代码来源:init_mooc_nb.py

示例15: test_cell_opts_util_style

    def test_cell_opts_util_style(self):
        mat1 = hv.Image(np.random.rand(5,5), name='mat1')
        self.assertEqual(mat1.id, None)
        opts("Image (cmap='hot')", mat1)
        self.assertNotEqual(mat1.id, None)

        self.assertEqual(
             Store.lookup_options('matplotlib',
                                  mat1, 'style').options.get('cmap',None),'hot')
开发者ID:mforbes,项目名称:holoviews,代码行数:9,代码来源:testutils.py


注:本文中的holoviews.Store类示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。