本文整理匯總了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()