當前位置: 首頁>>代碼示例>>Python>>正文


Python GlueUnSerializer.load方法代碼示例

本文整理匯總了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)
開發者ID:glue-viz,項目名稱:glue,代碼行數:33,代碼來源:application_base.py

示例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__')
開發者ID:crawfordsm,項目名稱:glue,代碼行數:22,代碼來源:application_base.py

示例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()
開發者ID:jzuhone,項目名稱:glue,代碼行數:25,代碼來源:test_session_back_compat.py


注:本文中的glue.core.state.GlueUnSerializer.load方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。