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


Python AnalysisDataService.add方法代码示例

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


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

示例1: test_addOrReplace_replaces_workspace_with_existing_name

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
 def test_addOrReplace_replaces_workspace_with_existing_name(self):
     data = [1.0,2.0,3.0]
     alg = run_algorithm('CreateWorkspace',DataX=data,DataY=data,NSpec=1,UnitX='Wavelength', child=True)
     name = "testws"
     ws = alg.getProperty("OutputWorkspace").value
     AnalysisDataService.add(name, ws)
     len_before = len(AnalysisDataService)
     AnalysisDataService.addOrReplace(name, ws)
     len_after = len(AnalysisDataService)
     self.assertEquals(len_after, len_before)
开发者ID:mantidproject,项目名称:mantid,代码行数:12,代码来源:AnalysisDataServiceTest.py

示例2: test_that_a_histogram_workspace_is_returned_as_a_MatrixWorkspace_from_ADS

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
    def test_that_a_histogram_workspace_is_returned_as_a_MatrixWorkspace_from_ADS(self):
        wsname = "MatrixWorkspaceTest_ADS"
        AnalysisDataService.add(wsname, self._test_ws)

        value = AnalysisDataService[wsname]
        self.assertTrue(isinstance(value, Workspace))
        # Have got a MatrixWorkspace back and not just the generic interface
        self.assertTrue(isinstance(value, MatrixWorkspace))
        mem = value.getMemorySize()
        self.assertTrue((mem > 0))

        AnalysisDataService.remove(wsname)
开发者ID:mantidproject,项目名称:mantid,代码行数:14,代码来源:MatrixWorkspaceTest.py

示例3: test_that_a_histogram_workspace_is_returned_as_a_MatrixWorkspace_from_a_property

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
    def test_that_a_histogram_workspace_is_returned_as_a_MatrixWorkspace_from_a_property(self):
        wsname = "MatrixWorkspaceTest_Property"
        AnalysisDataService.add(wsname, self._test_ws)

        alg = create_algorithm("Rebin", InputWorkspace=wsname)
        propValue = alg.getProperty("InputWorkspace").value
        # Is Workspace in the hierarchy of the value
        self.assertTrue(isinstance(propValue, Workspace))
        # Have got a MatrixWorkspace back and not just the generic interface
        self.assertTrue(isinstance(propValue, MatrixWorkspace))
        mem = propValue.getMemorySize()
        self.assertTrue((mem > 0))

        AnalysisDataService.remove(wsname)
开发者ID:mantidproject,项目名称:mantid,代码行数:16,代码来源:MatrixWorkspaceTest.py

示例4: test_MaskWorkspace_Is_Retrievable

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
    def test_MaskWorkspace_Is_Retrievable(self):
        dummy_ws = WorkspaceCreationHelper.create2DWorkspaceWithFullInstrument(2, 102, False) # no monitors
        ws_name = "dummy"
        AnalysisDataService.add(ws_name, dummy_ws)
        run_algorithm('MaskDetectors', Workspace=ws_name, WorkspaceIndexList=1)
        mask_name = 'mask_ws'
        run_algorithm('ExtractMask', InputWorkspace=ws_name, OutputWorkspace=mask_name)
        masked_ws = AnalysisDataService[mask_name]

        self.assertTrue(isinstance(masked_ws, IMaskWorkspace))
        self.assertEqual(1, masked_ws.getNumberMasked())
        # single number
        self.assertTrue(not masked_ws.isMasked(1))
        self.assertTrue(masked_ws.isMasked(2))
        # list
        self.assertTrue(not masked_ws.isMasked([1]))
        self.assertTrue(masked_ws.isMasked([2]))
开发者ID:dezed,项目名称:mantid,代码行数:19,代码来源:IMaskWorkspaceTest.py

示例5: test_pickle_table_workspace

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
    def test_pickle_table_workspace(self):
        from mantid.kernel import V3D
        import pickle

        table = TableWorkspace()
        table.addColumn(type="int",name="index")
        table.addColumn(type="str",name="value")
        table.addColumn(type="V3D",name="position")

        values = (1, '10', V3D(0, 0, 1))
        table.addRow(values)
        values = (2, '100', V3D(1, 0, 0))
        table.addRow(values)

        p = pickle.dumps(table)
        table2 = pickle.loads(p)
        self.assertEqual(table.toDict(), table2.toDict())

        # Can we add it to the ADS
        name = "test_pickle_table_workspace"
        AnalysisDataService.add(name, table2)
        self.assertTrue(name in AnalysisDataService)
        AnalysisDataService.remove(name)
开发者ID:samueljackson92,项目名称:mantid,代码行数:25,代码来源:ITableWorkspaceTest.py

示例6: _createMultiSpectra

# 需要导入模块: from mantid.api import AnalysisDataService [as 别名]
# 或者: from mantid.api.AnalysisDataService import add [as 别名]
 def _createMultiSpectra(self, wkspname):
     wksp = WCH.create2DWorkspaceWithFullInstrument(30, 5, False, False)
     AnalysisDataService.add(wkspname, wksp)
开发者ID:mantidproject,项目名称:mantid,代码行数:5,代码来源:SaveNexusPDTest.py


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