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


Python mtd.remove函数代码示例

本文整理汇总了Python中mantid.api.mtd.remove函数的典型用法代码示例。如果您正苦于以下问题:Python remove函数的具体用法?Python remove怎么用?Python remove使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


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

示例1: _cloneTestWorkspace

 def _cloneTestWorkspace(self, wsName=None):
     if not wsName:
         # Cannot use as default parameter as 'self' is not know in argument list.
         wsName = self._TEST_WS_NAME
     tempName = 'temp_testWS_'
     mtd.addOrReplace(tempName, self._testIN5WS)
     ws = CloneWorkspace(InputWorkspace=tempName,
                         OutputWorkspace=wsName)
     mtd.remove(tempName)
     return ws
开发者ID:DanNixon,项目名称:mantid,代码行数:10,代码来源:DirectILLApplySelfShieldingTest.py

示例2: test_SimpleAlgorithm_Accepts_Group_Handle

    def test_SimpleAlgorithm_Accepts_Group_Handle(self):
        from mantid.simpleapi import Scale
        self.create_matrix_workspace_in_ADS("First")
        self.create_matrix_workspace_in_ADS("Second")
        run_algorithm('GroupWorkspaces', InputWorkspaces='First,Second', OutputWorkspace='grouped')
        group = mtd['grouped']

        try:
            w = Scale(group, 1.5)
            mtd.remove(str(w))
        except Exception as exc:
            self.fail("Algorithm raised an exception with input as WorkspaceGroup: '" + str(exc) + "'")
        mtd.remove(str(group))
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:WorkspaceGroupTest.py

示例3: test_SimpleAlgorithm_Accepts_Group_Handle

    def test_SimpleAlgorithm_Accepts_Group_Handle(self):
        from mantid.simpleapi import Scale

        run_algorithm('CreateWorkspace', OutputWorkspace='First',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('CreateWorkspace', OutputWorkspace='Second',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('GroupWorkspaces',InputWorkspaces='First,Second',OutputWorkspace='group')
        group = mtd['group']
        self.assertEquals(group.getName(), "group")
        self.assertEquals(type(group), WorkspaceGroup)
        try:
            w = Scale(group, 1.5)
            mtd.remove(str(w))
        except Exception, exc:
            self.fail("Algorithm raised an exception with input as WorkspaceGroup: '" + str(exc) + "'")
开发者ID:liyulun,项目名称:mantid,代码行数:14,代码来源:WorkspaceGroupTest.py

示例4: setUp

 def setUp(self):
     if DirectILLDiagnosticsTest._TEST_WS is None:
         DirectILLDiagnosticsTest._TEST_WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL,
                                                                                       illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, DirectILLDiagnosticsTest._TEST_WS)
     kwargs = {
         'InputWorkspace': DirectILLDiagnosticsTest._TEST_WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'EPPCreationMethod': 'Fit EPP',
         'FlatBkg': 'Flat Bkg ON',
         'OutputEPPWorkspace': self._EPP_WS_NAME,
         'OutputRawWorkspace': self._RAW_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     mtd.remove(inWSName)
开发者ID:mantidproject,项目名称:mantid,代码行数:16,代码来源:DirectILLDiagnosticsTest.py

示例5: test_optional_workspaces_are_ignored_if_not_present_in_output_even_if_given_as_input

    def test_optional_workspaces_are_ignored_if_not_present_in_output_even_if_given_as_input(self):
        # Test algorithm
        from mantid.api import (
            AlgorithmManager,
            PropertyMode,
            PythonAlgorithm,
            MatrixWorkspaceProperty,
            WorkspaceFactory,
        )
        from mantid.kernel import Direction

        class OptionalWorkspace(PythonAlgorithm):
            def PyInit(self):
                self.declareProperty(MatrixWorkspaceProperty("RequiredWorkspace", "", Direction.Output))
                self.declareProperty(
                    MatrixWorkspaceProperty("OptionalWorkspace", "", Direction.Output, PropertyMode.Optional)
                )

            def PyExec(self):
                ws = WorkspaceFactory.create("Workspace2D", NVectors=1, YLength=1, XLength=1)
                ws.dataY(0)[0] = 5
                self.setProperty("RequiredWorkspace", ws)
                self.getLogger().notice("done!")

        AlgorithmFactory.subscribe(OptionalWorkspace)

        # temporarily attach it to simpleapi module
        name = "OptionalWorkspace"
        algm_object = AlgorithmManager.createUnmanaged(name, 1)
        algm_object.initialize()
        simpleapi._create_algorithm_function(name, 1, algm_object)  # Create the wrapper

        # Call with no optional output specified
        result = simpleapi.OptionalWorkspace(RequiredWorkspace="required")
        self.assertTrue(isinstance(result, MatrixWorkspace))
        self.assertAlmostEqual(5, result.readY(0)[0], places=12)
        mtd.remove("required")

        # Call with both outputs specified
        result = simpleapi.OptionalWorkspace(RequiredWorkspace="required", OptionalWorkspace="optional")
        self.assertTrue(isinstance(result, MatrixWorkspace))
        self.assertAlmostEqual(5, result.readY(0)[0], places=12)
        mtd.remove("required")

        # Tidy up simple api function
        del simpleapi.OptionalWorkspace
开发者ID:tyronerees,项目名称:mantid,代码行数:46,代码来源:SimpleAPITest.py

示例6: test_interface

    def test_interface(self):
        """ Rudimentary test to get peak and get/set some values """
        pws = mtd["peaks"]
        self.assertTrue(isinstance(pws, IPeaksWorkspace))
        self.assertEqual(pws.getNumberPeaks(), 1)
        p = pws.getPeak(0)

        # Try a few IPeak get/setters. Not everything.
        p.setH(234)
        self.assertEqual(p.getH(), 234)
        p.setHKL(5, 6, 7)
        self.assertEqual(p.getH(), 5)
        self.assertEqual(p.getK(), 6)
        self.assertEqual(p.getL(), 7)

        hkl = p.getHKL()
        self.assertEquals(hkl, V3D(5, 6, 7))

        p.setIntensity(456)
        p.setSigmaIntensity(789)
        self.assertEqual(p.getIntensity(), 456)
        self.assertEqual(p.getSigmaIntensity(), 789)

        # Finally try to remove a peak
        pws.removePeak(0)
        self.assertEqual(pws.getNumberPeaks(), 0)

        # Create a new peak at some Q in the lab frame
        qlab = V3D(1, 2, 3)
        p = pws.createPeak(qlab, 1.54)
        self.assertAlmostEquals(p.getQLabFrame().X(), 1.0, 3)

        # Now try to add the peak back
        pws.addPeak(p)
        self.assertEqual(pws.getNumberPeaks(), 1)

        # Check that it is what we added to it
        p = pws.getPeak(0)
        self.assertAlmostEquals(p.getQLabFrame().X(), 1.0, 3)

        # Peaks workspace will not be integrated by default.
        self.assertTrue(not pws.hasIntegratedPeaks())

        mtd.remove("cncs")
        mtd.remove("peaks")
开发者ID:trnielsen,项目名称:mantid,代码行数:45,代码来源:IPeaksWorkspaceTest.py

示例7: test_group_index_access_returns_correct_workspace

    def test_group_index_access_returns_correct_workspace(self):
        run_algorithm('CreateWorkspace', OutputWorkspace='First',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('CreateWorkspace', OutputWorkspace='Second',DataX=[4.,5.,6.], DataY=[4.,5.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('CreateWorkspace', OutputWorkspace='Third',DataX=[7.,8.,9.], DataY=[6.,7.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('GroupWorkspaces',InputWorkspaces='First,Second,Third',OutputWorkspace='grouped')
        group = mtd['grouped']

        self.assertRaises(IndexError, group.__getitem__, 3) # Index out of bounds
        for i in range(3):
            member = group[i]
            self.assertTrue(isinstance(member, MatrixWorkspace))

        # Clearing the data should leave the handle unusable
        member = group[0]
        mtd.remove("First")
        try:
            member.name()
            self.fail("Handle for item extracted from WorkspaceGroup is still usable after ADS has been cleared, it should be a weak reference and raise an error.")
        except RuntimeError as exc:
            self.assertEquals(str(exc), 'Variable invalidated, data has been deleted.')
开发者ID:DanNixon,项目名称:mantid,代码行数:20,代码来源:WorkspaceGroupTest.py

示例8: test_later_store_in_ADS

    def test_later_store_in_ADS(self):
        from mantid.api import MatrixWorkspaceProperty
        from mantid.kernel import Direction

        class SimpleAPIPythonAlgorithm6(PythonAlgorithm):
            def PyInit(self):
                self.declareProperty(MatrixWorkspaceProperty("OutputWorkspace", "", Direction.Output))

            def PyExec(self):
                from mantid.simpleapi import CreateSampleWorkspace
                workspaceNotInADS = CreateSampleWorkspace(StoreInADS=False)
                assert(workspaceNotInADS)
                self.setProperty("OutputWorkspace", workspaceNotInADS)
        AlgorithmFactory.subscribe(SimpleAPIPythonAlgorithm6)

        alg = SimpleAPIPythonAlgorithm6()
        alg.initialize()
        alg.setPropertyValue("OutputWorkspace", "out")
        alg.execute()
        self.assertTrue('out' in mtd)
        mtd.remove('out')
开发者ID:mantidproject,项目名称:mantid,代码行数:21,代码来源:SimpleAPITest.py

示例9: setUp

 def setUp(self):
     if not self._testIN5WS:
         self._testIN5WS = illhelpers.create_poor_mans_in5_workspace(self._BKG_LEVEL,
                                                                     illhelpers.default_test_detectors)
     inWSName = 'inputWS'
     mtd.addOrReplace(inWSName, self._testIN5WS)
     kwargs = {
         'InputWorkspace': self._testIN5WS,
         'OutputWorkspace': self._TEST_WS_NAME,
         'OutputEPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLCollectData', **kwargs)
     kwargs = {
         'InputWorkspace': self._TEST_WS_NAME,
         'OutputWorkspace': self._VANADIUM_WS_NAME,
         'EPPWorkspace': self._EPP_WS_NAME
     }
     run_algorithm('DirectILLIntegrateVanadium', **kwargs)
     vanadiumWS = mtd[self._VANADIUM_WS_NAME]
     for i in range(vanadiumWS.getNumberHistograms()):
         vanadiumYs = vanadiumWS.dataY(i)
         vanadiumYs.fill(1.0)
     mtd.remove(inWSName)
开发者ID:DanNixon,项目名称:mantid,代码行数:23,代码来源:DirectILLReductionTest.py

示例10: test_complex_binary_operations_with_group_do_not_leave_temporary_workspaces_in_ADS

    def test_complex_binary_operations_with_group_do_not_leave_temporary_workspaces_in_ADS(self):
        run_algorithm('CreateWorkspace', OutputWorkspace='grouped_1',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('CreateWorkspace', OutputWorkspace='grouped_2',DataX=[1.,2.,3.], DataY=[2.,3.], DataE=[2.,3.],UnitX='TOF')
        run_algorithm('GroupWorkspaces',InputWorkspaces='grouped_1,grouped_2',OutputWorkspace='grouped')

        w1=(mtd['grouped']*0.0)+1.0

        self.assertTrue('w1' in mtd)
        self.assertTrue('grouped' in mtd)
        self.assertTrue('grouped_1' in mtd)
        self.assertTrue('grouped_2' in mtd)
        self.assertTrue('__python_op_tmp0' not in mtd)
        self.assertTrue('__python_op_tmp0_1' not in mtd)
        self.assertTrue('__python_op_tmp0_2' not in mtd)

        mtd.remove('w1')
        mtd.remove('grouped')
        mtd.remove('grouped_1')
        mtd.remove('grouped_2')
开发者ID:DanNixon,项目名称:mantid,代码行数:19,代码来源:WorkspaceGroupTest.py

示例11: tearDown

 def tearDown(self):
     for wsName in mtd.getObjectNames():
         if wsName.startswith(self.prefix):
             mtd.remove(wsName)
开发者ID:rosswhitfield,项目名称:mantid,代码行数:4,代码来源:ILLD2BTest.py

示例12: test_vanilla_python_default_in_ADS

 def test_vanilla_python_default_in_ADS(self):
     from mantid.simpleapi import CreateSampleWorkspace
     out = CreateSampleWorkspace()
     self.assertTrue(out)
     self.assertTrue('out' in mtd)
     mtd.remove('out')
开发者ID:mantidproject,项目名称:mantid,代码行数:6,代码来源:SimpleAPITest.py

示例13: _clear

 def _clear(self, expected):
     for workspace in expected:
         mtd.remove(workspace)
开发者ID:mantidproject,项目名称:mantid,代码行数:3,代码来源:ReflectometryISISLoadAndProcessTest.py

示例14: test_vanilla_python_explicit_in_ADS

 def test_vanilla_python_explicit_in_ADS(self):
     from mantid.simpleapi import CreateSampleWorkspace
     out = CreateSampleWorkspace(StoreInADS=True)
     self.assertTrue(out)
     self.assertTrue('out' in mtd)
     mtd.remove('out')
开发者ID:mantidproject,项目名称:mantid,代码行数:6,代码来源:SimpleAPITest.py

示例15: cleanFit

def cleanFit():
    """Removes workspaces created during the fit"""
    mtd.remove('data')
    mtd.remove('fit_NormalisedCovarianceMatrix')
    mtd.remove('fit_Parameters')
    mtd.remove('fit_Workspace')
开发者ID:mantidproject,项目名称:mantid,代码行数:6,代码来源:StretchedExpFTTestHelper.py


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