本文整理汇总了Python中glue.core.state.GlueUnSerializer.load方法的典型用法代码示例。如果您正苦于以下问题:Python GlueUnSerializer.load方法的具体用法?Python GlueUnSerializer.load怎么用?Python GlueUnSerializer.load使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类glue.core.state.GlueUnSerializer
的用法示例。
在下文中一共展示了GlueUnSerializer.load方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: restore_session
# 需要导入模块: from glue.core.state import GlueUnSerializer [as 别名]
# 或者: from glue.core.state.GlueUnSerializer import load [as 别名]
def restore_session(path):
"""
Reload a previously-saved session
Parameters
----------
path : str
Path to the file to load
Returns
-------
app : :class:`Application`
The loaded application
"""
from glue.core.state import GlueUnSerializer
# In case relative paths are needed in the session file, we do the
# loading while setting the current directory to the directory
# in which the session file is so that relative paths are interpreted
# as relative to the session file.
start_dir = os.path.abspath('.')
session_dir = os.path.dirname(path) or '.'
session_file = os.path.basename(path)
try:
os.chdir(session_dir)
with open(session_file) as infile:
state = GlueUnSerializer.load(infile)
return state.object('__main__')
finally:
os.chdir(start_dir)
示例2: restore_session
# 需要导入模块: from glue.core.state import GlueUnSerializer [as 别名]
# 或者: from glue.core.state.GlueUnSerializer import load [as 别名]
def restore_session(path):
"""
Reload a previously-saved session
Parameters
----------
path : str
Path to the file to load
Returns
-------
app : :class:`Application`
The loaded application
"""
from glue.core.state import GlueUnSerializer
with open(path) as infile:
state = GlueUnSerializer.load(infile)
return state.object('__main__')
示例3: test_table_widget_010
# 需要导入模块: from glue.core.state import GlueUnSerializer [as 别名]
# 或者: from glue.core.state.GlueUnSerializer import load [as 别名]
def test_table_widget_010():
from glue.viewers.table.qt.tests.test_data_viewer import check_values_and_color
# This loads a session file made with Glue v0.10 that includes a table
# viewer. This is to make sure that loading table viewers from old files
# will always be backward-compatible.
with open(os.path.join(DATA, 'glue_v0.10_table.glu'), 'r') as f:
state = GlueUnSerializer.load(f)
ga = state.object('__main__')
viewer = ga.viewers[0][0]
data = {'x': [1, 2, 3],
'y': [4, 5, 6]}
colors = ['#e31a1c', '#6d7326', None]
check_values_and_color(viewer.model, data, colors)
ga.close()