当前位置: 首页>>代码示例>>Python>>正文


Python AnalysisDataService.clear方法代码示例

本文整理汇总了Python中mantid.api.AnalysisDataService.clear方法的典型用法代码示例。如果您正苦于以下问题:Python AnalysisDataService.clear方法的具体用法?Python AnalysisDataService.clear怎么用?Python AnalysisDataService.clear使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在mantid.api.AnalysisDataService的用法示例。


在下文中一共展示了AnalysisDataService.clear方法的13个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: open_selected_in_editor

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def open_selected_in_editor(self, selected):
        """
        Open the passed checkpoint in the editor
        :param selected: String; Checkpoint name to be opened
        """
        self.is_recovery_running = True
        ADS.clear()

        # Open editor for this checkpoint
        pid_dir = self.project_recovery.get_pid_folder_to_load_a_checkpoint_from()
        selected = selected.replace(" ", "T")
        checkpoint = os.path.join(pid_dir, selected)

        try:
            self.project_recovery.open_checkpoint_in_script_editor(checkpoint)
        except Exception as e:
            if isinstance(e, KeyboardInterrupt):
                raise
            # Fail "silently"
            self.has_failed_run = True

        if self.has_failed_run:
            self._update_checkpoint_tried(selected)

        self.is_recovery_running = False
        self.presenter.close_view()
开发者ID:mantidproject,项目名称:mantid,代码行数:28,代码来源:projectrecoverymodel.py

示例2: recover_selected_checkpoint

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def recover_selected_checkpoint(self, selected):
        """
        Recover the passed checkpoint
        :param selected: String; Checkpoint name to be recovered
        """
        # If this is a valid file then it should only be the checkpoint here
        if os.path.exists(selected):
            selected = os.path.basename(selected)

        self.is_recovery_running = True
        self.presenter.change_start_mantid_to_cancel_label()

        ADS.clear()

        # Recover given the checkpoint selected
        pid_dir = self.project_recovery.get_pid_folder_to_load_a_checkpoint_from()
        selected = selected.replace(" ", "T")
        checkpoint = os.path.join(pid_dir, selected)
        self.selected_checkpoint = selected

        try:
            self._start_recovery_of_checkpoint(checkpoint)
        except Exception as e:
            # Fail "Silently" by setting failed run to true, setting checkpoint to tried and closing the view.
            logger.debug("Project Recovery: " + str(e))
            self.has_failed_run = True
            self._update_checkpoint_tried(selected)
            self.presenter.close_view()
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:projectrecoverymodel.py

示例3: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def tearDown(self):
        ADS.clear()
        if os.path.exists(self.pr.recovery_directory_hostname):
            shutil.rmtree(self.pr.recovery_directory_hostname)

        if os.path.exists(self.working_directory):
            shutil.rmtree(self.working_directory)
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:test_projectrecoverysaver.py

示例4: test_observeClear_calls_clearHandle_when_set_on_ads_its_cleared

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def test_observeClear_calls_clearHandle_when_set_on_ads_its_cleared(self):
        CreateSampleWorkspace(OutputWorkspace="ws")

        self.fake_class.observeClear(True)
        self.fake_class.clearHandle = mock.MagicMock()
        ADS.clear()

        self.assertEqual(self.fake_class.clearHandle.call_count, 1)
开发者ID:mantidproject,项目名称:mantid,代码行数:10,代码来源:AnalysisDataServiceObserverTest.py

示例5: test_observeAll_calls_anyChangeHandle_when_set_on_ads_clear

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def test_observeAll_calls_anyChangeHandle_when_set_on_ads_clear(self):
        self.fake_class.observeAll(True)
        CreateSampleWorkspace(OutputWorkspace="ws")
        expected_count = 1

        # Will replace first workspace
        ADS.clear()
        expected_count += 1

        self.assertEqual(self.fake_class.anyChangeHandle.call_count, expected_count)
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:AnalysisDataServiceObserverTest.py

示例6: test_load_calls_loads_successfully

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def test_load_calls_loads_successfully(self):
        working_directory = tempfile.mkdtemp()
        return_value_for_load = os.path.join(working_directory, os.path.basename(working_directory) + ".mtdproj")
        self.project._save_file_dialog = mock.MagicMock(return_value=working_directory)
        CreateSampleWorkspace(OutputWorkspace="ws1")
        self.project.save_as()

        self.assertEqual(self.project._save_file_dialog.call_count, 1)
        ADS.clear()

        self.project._load_file_dialog = mock.MagicMock(return_value=return_value_for_load)
        self.project.load()
        self.assertEqual(self.project._load_file_dialog.call_count, 1)
        self.assertEqual(["ws1"], ADS.getObjectNames())
开发者ID:samueljackson92,项目名称:mantid,代码行数:16,代码来源:test_project.py

示例7: setUp

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def setUp(self):
        AnalysisDataService.clear()
        self.filepath = FileFinder.findRuns('EMU00019489.nxs')[0]
        self.load_result, self.run_number, self.filename = load_workspace_from_filename(self.filepath)
        self.loaded_data = MuonLoadData()
        self.data_context = MuonDataContext(self.loaded_data)
        self.gui_context = MuonGuiContext()
        self.group_pair_context = MuonGroupPairContext()
        self.gui_context.update({'RebinType': 'None'})

        self.context = MuonContext(muon_data_context=self.data_context, muon_gui_context=self.gui_context, muon_group_context=self.group_pair_context)

        self.data_context.instrument = 'EMU'

        self.loaded_data.add_data(workspace=self.load_result, run=[self.run_number], filename=self.filename,
                                  instrument='EMU')
        self.data_context.current_runs = [[self.run_number]]
        self.data_context.update_current_data()
        self.group_pair_context.reset_group_and_pairs_to_default(self.load_result['OutputWorkspace'][0]._workspace,
                                                                 'EMU', '')
开发者ID:mantidproject,项目名称:mantid,代码行数:22,代码来源:muon_context_test.py

示例8: test_recovery_save_with_just_interfaces

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def test_recovery_save_with_just_interfaces(self, windows_that_are_savable):
        CreateSampleWorkspace(OutputWorkspace="ws")
        # Return a FakeEncoder object that will return an empty dictionary
        windows_that_are_savable.return_value = [[FakeEncoder(), FakeEncoder()]]
        self.pr_saver._spin_off_another_time_thread = mock.MagicMock()
        ADS.clear()

        self.pr_saver.gfm = mock.MagicMock()
        self.pr_saver.gfm.figs = {}

        self.pr_saver.recovery_save()

        # Check no 0.py was made
        checkpoint = self.pr.listdir_fullpath(self.pr.recovery_directory_pid)[0]
        self.assertTrue(not os.path.exists(os.path.join(checkpoint, "0.py")))
        self.assertEqual(self.pr_saver._spin_off_another_time_thread.call_count, 1)

        # Read the .json file and check nothing is in workspace and something is in the interfaces dictionary
        with open(os.path.join(checkpoint, (os.path.basename(checkpoint) + self.pr.recovery_file_ext))) as f:
            dictionary = json.load(f)
            self.assertEqual(len(dictionary["interfaces"]), 1)
            self.assertEqual(len(dictionary["workspaces"]), 0)
开发者ID:mantidproject,项目名称:mantid,代码行数:24,代码来源:test_projectrecoverysaver.py

示例9: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
 def tearDown(self):
     ADS.clear()
     if isdir(self.working_directory):
         rmtree(self.working_directory)
开发者ID:mantidproject,项目名称:mantid,代码行数:6,代码来源:test_workspacesaver.py

示例10: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
 def tearDown(self):
     ADS.clear()
开发者ID:samueljackson92,项目名称:mantid,代码行数:4,代码来源:test_project.py

示例11: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
 def tearDown(self):
     AnalysisDataService.clear()
开发者ID:mantidproject,项目名称:mantid,代码行数:4,代码来源:frequency_domain_context_test.py

示例12: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
 def tearDown(self):
     self.fake_class.observeAll(False)
     ADS.clear()
开发者ID:mantidproject,项目名称:mantid,代码行数:5,代码来源:AnalysisDataServiceObserverTest.py

示例13: tearDown

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import clear [as 别名]
    def tearDown(self):
        # Make sure to clear the hostname layer between tests
        ADS.clear()

        if os.path.exists(self.pid):
            shutil.rmtree(self.pid)
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:test_projectrecoverymodel.py


注:本文中的mantid.api.AnalysisDataService.clear方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。