本文整理汇总了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
示例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))
示例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) + "'")
示例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)
示例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
示例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")
示例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.')
示例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')
示例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)
示例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')
示例11: tearDown
def tearDown(self):
for wsName in mtd.getObjectNames():
if wsName.startswith(self.prefix):
mtd.remove(wsName)
示例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')
示例13: _clear
def _clear(self, expected):
for workspace in expected:
mtd.remove(workspace)
示例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')
示例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')