本文整理汇总了Python中holoviews.Store.lookup_options方法的典型用法代码示例。如果您正苦于以下问题:Python Store.lookup_options方法的具体用法?Python Store.lookup_options怎么用?Python Store.lookup_options使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类holoviews.Store
的用法示例。
在下文中一共展示了Store.lookup_options方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_mpl_bokeh_offset_mpl
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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
示例2: test_custom_magic_to_default_inheritance
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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)
示例3: test_mpl_bokeh_mpl_via_dict_backend_keyword
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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')
示例4: test_style_inheritance_addition
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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)
示例5: test_style_transfer
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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'})
示例6: test_style_transfer
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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'})
示例7: test_mpl_bokeh_mpl_via_builders_opts_method
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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)
示例8: test_specification_general_to_specific_group_and_label
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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})
示例9: test_custom_call_to_default_inheritance
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
def test_custom_call_to_default_inheritance(self):
"""
Checks customs inheritance backs off to default tree correctly
using __call__.
"""
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')
expected_obj = {'alpha': 0.2, 'cmap': 'hot', 'interpolation': 'nearest'}
obj_lookup = Store.lookup_options('matplotlib', obj, 'style')
self.assertEqual(obj_lookup.kwargs, expected_obj)
# Customize this particular object
custom_obj = obj(style=dict(clims=(0, 0.5)))
expected_custom_obj = dict(clims=(0,0.5), **expected_obj)
custom_obj_lookup = Store.lookup_options('matplotlib', custom_obj, 'style')
self.assertEqual(custom_obj_lookup.kwargs, expected_custom_obj)
示例10: test_cell_opts_util_style
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
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')
示例11: test_cell_opts_util_norm
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
def test_cell_opts_util_norm(self):
mat1 = hv.Image(np.random.rand(5,5), name='mat1')
self.assertEqual(mat1.id, None)
opts("Image {+axiswise}", mat1)
self.assertNotEqual(mat1.id, None)
self.assertEqual(
Store.lookup_options('matplotlib',
mat1, 'norm').options.get('axiswise',True), True)
示例12: test_mpl_bokeh_output_options_group_expandable
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [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
示例13: test_cell_opts_util_plot
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
def test_cell_opts_util_plot(self):
mat1 = hv.Image(np.random.rand(5,5), name='mat1')
self.assertEqual(mat1.id, None)
opts("Image [show_title=False]", mat1)
self.assertNotEqual(mat1.id, None)
self.assertEqual(
Store.lookup_options('matplotlib',
mat1, 'plot').options.get('show_title',True),False)
示例14: test_pickle_mpl_bokeh
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
def test_pickle_mpl_bokeh(self):
"""
Test pickle saving and loading with Store (style information preserved)
"""
fname = 'test_pickle_mpl_bokeh.pkl'
raw = super(TestCrossBackendOptionPickling, self).test_mpl_bokeh_mpl()
Store.dump(raw, open(fname,'wb'))
self.clear_options()
img = Store.load(open(fname,'rb'))
# Data should match
self.assertEqual(raw, img)
# 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'})
示例15: test_raw_pickle
# 需要导入模块: from holoviews import Store [as 别名]
# 或者: from holoviews.Store import lookup_options [as 别名]
def test_raw_pickle(self):
"""
Test usual pickle saving and loading (no style information preserved)
"""
fname= 'test_raw_pickle.pkl'
raw = super(TestCrossBackendOptionPickling, self).test_mpl_bokeh_mpl()
pickle.dump(raw, open(fname,'wb'))
self.clear_options()
img = pickle.load(open(fname,'rb'))
# Data should match
self.assertEqual(raw, img)
# But the styles will be lost without using Store.load/Store.dump
pickle.current_backend = 'matplotlib'
mpl_opts = Store.lookup_options('matplotlib', img, 'style').options
self.assertEqual(mpl_opts, {})
# ... across all backends
Store.current_backend = 'bokeh'
bokeh_opts = Store.lookup_options('bokeh', img, 'style').options
self.assertEqual(bokeh_opts, {})