本文整理汇总了Python中holoviews.core.options.Store类的典型用法代码示例。如果您正苦于以下问题:Python Store类的具体用法?Python Store怎么用?Python Store使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Store类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: tearDown
def tearDown(self):
Store._weakrefs = {}
Store._options.pop('backend_1')
Store._options.pop('backend_2')
Store._custom_options.pop('backend_1')
Store._custom_options.pop('backend_2')
Store.set_current_backend(self.current_backend)
示例2: test_apply_options_when_backend_switched
def test_apply_options_when_backend_switched(self):
obj = TestObj([])
Store.current_backend = 'backend_2'
obj.opts(style_opt1='A', plot_opt1='B')
Store.current_backend = 'backend_1'
obj.opts(style_opt1='C', plot_opt1='D', backend='backend_2')
plot_opts = Store.lookup_options('backend_2', obj, 'plot')
assert plot_opts.options == {'plot_opt1': 'D'}
style_opts = Store.lookup_options('backend_2', obj, 'style')
assert style_opts.options == {'style_opt1': 'C'}
示例3: test_overlay_options_complete
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])({"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")
示例4: test_apply_options_explicit_backend_persists_other_backend_inverted
def test_apply_options_explicit_backend_persists_other_backend_inverted(self):
obj = TestObj([])
obj.opts(style_opt1='A', plot_opt1='B', backend='backend_2')
obj.opts(style_opt1='C', plot_opt1='D', backend='backend_1')
plot_opts = Store.lookup_options('backend_1', obj, 'plot')
assert plot_opts.options == {'plot_opt1': 'D'}
style_opts = Store.lookup_options('backend_1', obj, 'style')
assert style_opts.options == {'style_opt1': 'C'}
plot_opts = Store.lookup_options('backend_2', obj, 'plot')
assert plot_opts.options == {'plot_opt1': 'B'}
style_opts = Store.lookup_options('backend_2', obj, 'style')
assert style_opts.options == {'style_opt1': 'A'}
示例5: test_cell_opts_norm
def test_cell_opts_norm(self):
self.cell("mat1 = Image(np.random.rand(5,5), name='mat1')")
self.assertEqual(self.get_object('mat1').id, None)
self.cell_magic('opts', " Image {+axiswise}", 'mat1')
self.assertEqual(self.get_object('mat1').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
self.assertEqual(
Store.lookup_options('matplotlib',
self.get_object('mat1'), 'norm').options.get('axiswise',True), True)
示例6: test_cell_opts_plot
def test_cell_opts_plot(self):
self.cell("mat1 = Image(np.random.rand(5,5), name='mat1')")
self.assertEqual(self.get_object('mat1').id, None)
self.cell_magic('opts', " Image [show_title=False]", 'mat1')
self.assertEqual(self.get_object('mat1').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
self.assertEqual(
Store.lookup_options('matplotlib',
self.get_object('mat1'), 'plot').options.get('show_title',True),False)
示例7: test_cell_opts_style
def test_cell_opts_style(self):
self.cell("mat1 = Image(np.random.rand(5,5), name='mat1')")
self.assertEqual(self.get_object('mat1').id, None)
self.cell_magic('opts', " Image (cmap='hot')", 'mat1')
self.assertEqual(self.get_object('mat1').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
self.assertEqual(
Store.lookup_options('matplotlib',
self.get_object('mat1'), 'style').options.get('cmap',None),'hot')
示例8: test_cell_opts_plot_dynamic
def test_cell_opts_plot_dynamic(self):
self.cell("dmap = DynamicMap(lambda X: Image(np.random.rand(5,5), name='dmap'), kdims=['x'])"
".redim.range(x=(0, 10)).opts(plot={'Image': dict(xaxis='top', xticks=3)})")
self.assertEqual(self.get_object('dmap').id, None)
self.cell_magic('opts', " Image [xaxis=None yaxis='right']", 'dmap')
self.assertEqual(self.get_object('dmap').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
opts = Store.lookup_options('matplotlib', self.get_object('dmap')[0], 'plot').options
self.assertEqual(opts, {'xticks': 3, 'xaxis': None, 'yaxis': 'right'})
示例9: test_cell_opts_plot_float_division
def test_cell_opts_plot_float_division(self):
self.cell("mat1 = Image(np.random.rand(5,5), name='mat1')")
self.assertEqual(self.get_object('mat1').id, None)
self.cell_magic('opts', " Image [aspect=3/4]", 'mat1')
self.assertEqual(self.get_object('mat1').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
self.assertEqual(
Store.lookup_options('matplotlib',
self.get_object('mat1'), 'plot').options.get('aspect',False), 3/4.0)
示例10: test_cell_opts_style_dynamic
def test_cell_opts_style_dynamic(self):
self.cell("dmap = DynamicMap(lambda X: Curve(np.random.rand(5,2), name='dmap'), kdims=['x'])"
".redim.range(x=(0, 10)).opts(style={'Curve': dict(linewidth=2, color='black')})")
self.assertEqual(self.get_object('dmap').id, None)
self.cell_magic('opts', " Curve (linewidth=3 alpha=0.5)", 'dmap')
self.assertEqual(self.get_object('dmap').id, 0)
assert 0 in Store.custom_options(), "Custom OptionTree creation failed"
opts = Store.lookup_options('matplotlib', self.get_object('dmap')[0], 'style').options
self.assertEqual(opts, {'linewidth': 3, 'alpha': 0.5, 'color': 'black'})
示例11: test_overlay_options_partitioned
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])(
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")
示例12: test_dynamic_opts_link_inputs
def test_dynamic_opts_link_inputs(self):
stream = LinkedStream()
inputs = [DynamicMap(lambda: None, streams=[stream])]
dmap = DynamicMap(Callable(lambda X: TestObj(None), inputs=inputs),
kdims=['X']).redim.range(X=(0,10))
styled_dmap = dmap.options(plot_opt1='red', clone=False)
opts = Store.lookup_options('backend_1', dmap[0], 'plot')
self.assertEqual(opts.options, {'plot_opt1': 'red'})
self.assertIs(styled_dmap, dmap)
self.assertTrue(dmap.callback.link_inputs)
unstyled_dmap = dmap.callback.inputs[0].callback.inputs[0]
opts = Store.lookup_options('backend_1', unstyled_dmap[0], 'plot')
self.assertEqual(opts.options, {})
original_dmap = unstyled_dmap.callback.inputs[0]
self.assertIs(stream, original_dmap.streams[0])
示例13: test_layout_options_long_style
def test_layout_options_long_style(self):
"""
The old (longer) syntax in __call__
"""
im = Image(np.random.rand(10, 10))
layout = (im + im)({"Layout": dict(plot={"hspace": 10})})
self.assertEqual(Store.lookup_options("matplotlib", layout, "plot").kwargs["hspace"], 10)
示例14: test_layout_options_short_style
def test_layout_options_short_style(self):
"""
Short __call__ syntax.
"""
im = Image(np.random.rand(10, 10))
layout = (im + im)({"Layout": dict(plot={"hspace": 5})})
self.assertEqual(Store.lookup_options("matplotlib", layout, "plot").kwargs["hspace"], 5)
示例15: _set_style
def _set_style(self, feature, map_type):
fname = feature.name.capitalize()
style_path = ('Image', fname + map_type.capitalize())
options = Store.options(backend='matplotlib')
if style_path not in options.data:
cyclic = True if feature.cyclic and not map_type == 'selectivity' else False
options[style_path] = Options('style', **(dict(cmap='hsv') if cyclic else dict()))