• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

Python testhelpers.create_algorithm函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: create_sample_workspace

 def create_sample_workspace(self, name, numMonitors=0):
     args = {
         'OutputWorkspace': name,
         'Function': 'Flat background',
         'NumMonitors': numMonitors,
         'NumBanks': 1,
     }
     alg = create_algorithm('CreateSampleWorkspace', **args)
     alg.setLogging(False)
     alg.execute()
     loadInstrArgs = {
         'Workspace': name,
         'InstrumentName': 'FIGARO',
         'RewriteSpectraMap': False
     }
     loadInstrument = create_algorithm('LoadInstrument', **loadInstrArgs)
     loadInstrument.setLogging(False)
     loadInstrument.execute()
     addSampleLogArgs = {
         'Workspace': name,
         'LogType': 'Number',
         'LogName': common.SampleLogs.TWO_THETA,
         'NumberType': 'Double',
         'LogText': '5.6',
         'LogUnit': 'degree'
     }
     addSampleLog = create_algorithm('AddSampleLog', **addSampleLogArgs)
     addSampleLog.setLogging(False)
     addSampleLog.execute()
     self.assertEquals(mtd.getObjectNames(), [name])
开发者ID:mantidproject,项目名称:mantid,代码行数:30,代码来源:ReflectometryILLPreprocessTest.py


示例2: testReflectedBeamSumInQExecutes

 def testReflectedBeamSumInQExecutes(self):
     dirWS = illhelpers.create_poor_mans_d17_workspace()
     illhelpers.add_chopper_configuration_D17(dirWS)
     illhelpers.add_slit_configuration_D17(dirWS, 0.02, 0.03)
     dirBeamPosWS = illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128)
     dirWS = illhelpers.refl_preprocess('dirWS', dirWS, dirBeamPosWS)
     args = {
         'InputWorkspace': dirWS,
         'OutputWorkspace': 'dirForeground',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLSumForeground', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
     dirForeground = alg.getProperty('OutputWorkspace').value
     reflWS = illhelpers.create_poor_mans_d17_workspace()
     illhelpers.refl_rotate_detector(reflWS, 1.2)
     illhelpers.add_chopper_configuration_D17(reflWS)
     illhelpers.add_slit_configuration_D17(reflWS, 0.02, 0.03)
     reflBeamPosWS = illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.2, 128)
     reflWS = illhelpers.refl_preprocess('refWS', reflWS, reflBeamPosWS)
     args = {
         'InputWorkspace': reflWS,
         'OutputWorkspace': 'foreground',
         'DirectForegroundWorkspace': dirForeground,
         'SummationType': 'SumInQ',
         'DirectBeamWorkspace': dirWS,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLSumForeground', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
开发者ID:samueljackson92,项目名称:mantid,代码行数:34,代码来源:ReflectometryILLSumForegroundTest.py


示例3: testFigaroSumInLambdaExecutes

 def testFigaroSumInLambdaExecutes(self):
     args = {
         'Run': 'ILL/Figaro/000002.nxs',
         'OutputWorkspace': 'direct',
         'ForegroundHalfWidth': [6, 6],
         'FlatBackground': 'Background OFF',
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
     args = {
         'InputWorkspace': 'direct',
         'OutputWorkspace': 'direct-fgd'
     }
     alg = create_algorithm('ReflectometryILLSumForeground', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
     args = {
         'Run': 'ILL/Figaro/000002.nxs',
         'OutputWorkspace': 'reflected',
         'ForegroundHalfWidth': [6, 6],
         'FlatBackground': 'Background OFF',
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
     args = {
         'InputWorkspace': 'reflected',
         'OutputWorkspace': 'reflected-fgd',
         'DirectForegroundWorkspace': 'direct-fgd',
         'DirectBeamWorkspace': 'direct'
     }
     alg = create_algorithm('ReflectometryILLSumForeground', **args)
     assertRaisesNothing(self, alg.execute)
     self.assertTrue(alg.isExecuted())
开发者ID:samueljackson92,项目名称:mantid,代码行数:35,代码来源:ReflectometryILLSumForegroundTest.py


示例4: setUp

 def setUp(self):
     if self._integration is None:
         self.__class__._integration = create_algorithm("Integration")
         self.__class__._integration.initialize()
     if self._mask_dets is None:
         self.__class__._mask_dets = create_algorithm("MaskDetectors")
         self.__class__._mask_dets.initialize()
开发者ID:mantidproject,项目名称:mantid,代码行数:7,代码来源:PropertyWithValueTest.py


示例5: test_all_child_properties_are_present

 def test_all_child_properties_are_present(self):
     # Get the properties for the child algorithm, apart from a list of known
     # exclusions
     child_alg = create_algorithm('ReflectometryReductionOneAuto')
     excluded = ['ThetaIn', 'ThetaLogName', 'Diagnostics',
                 'OutputWorkspaceBinned', 'OutputWorkspaceWavelength']
     child_props = set([prop.name for prop in child_alg.getProperties() if prop.name not in excluded])
     # Check the child properties exist in the parent algorithm
     actual_alg = create_algorithm('ReflectometryReductionOneLiveData')
     actual_props = set([prop.name for prop in actual_alg.getProperties()])
     if not child_props.issubset(actual_props):
         assert False, "The following child properties are not implemented in the parent algorithm:\n" \
         + str(child_props.difference(actual_props))
开发者ID:mantidproject,项目名称:mantid,代码行数:13,代码来源:ReflectometryReductionOneLiveDataTest.py


示例6: testWaterWorkspace

 def testWaterWorkspace(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     # Add a peak to the sample workspace.
     ws = mtd[inWSName]
     for i in range(ws.getNumberHistograms()):
         ys = ws.dataY(i)
         ys.fill(10.27)
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'WaterWorkspace': inWSName,
         'FluxNormalisation': 'Normalisation OFF',
         'FlatBackground': 'Background OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     ysSize = outWS.blocksize()
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         numpy.testing.assert_equal(ys, [1.0] * ysSize)
     self.assertEquals(mtd.getObjectNames(), ['ReflectometryILLPreprocess_test_ws'])
开发者ID:mantidproject,项目名称:mantid,代码行数:26,代码来源:ReflectometryILLPreprocessTest.py


示例7: _backgroundSubtraction

 def _backgroundSubtraction(self, subtractionType):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     # Add a peak to the sample workspace.
     ws = mtd[inWSName]
     ys = ws.dataY(49)
     ys += 10.0
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'LinePosition': 49,
         'FluxNormalisation': 'Normalisation OFF',
         'FlatBackground': subtractionType,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     ysSize = outWS.blocksize()
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         if i != 49:
             numpy.testing.assert_almost_equal(ys, [0.0] * ysSize)
         else:
             numpy.testing.assert_almost_equal(ys, [10.0] * ysSize)
     self.assertEquals(mtd.getObjectNames(), ['ReflectometryILLPreprocess_test_ws'])
开发者ID:mantidproject,项目名称:mantid,代码行数:28,代码来源:ReflectometryILLPreprocessTest.py


示例8: testForegroundBackgroundRanges

 def testForegroundBackgroundRanges(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     ws = mtd[inWSName]
     # Add special background fitting zones around the exclude zones.
     lowerBkgIndices = [26]
     for i in lowerBkgIndices:
         ys = ws.dataY(i)
         ys += 5.0
     # Add negative 'exclude zone' around the peak.
     lowerExclusionIndices = [27, 28]
     for i in lowerExclusionIndices:
         ys = ws.dataY(i)
         ys -= 1000.0
     # Add a peak to the sample workspace.
     foregroundIndices = [29, 30, 31]
     for i in foregroundIndices:
         ys = ws.dataY(i)
         ys += 1000.0
     # The second exclusion zone is wider.
     upperExclusionIndices = [32, 33, 34]
     for i in upperExclusionIndices:
         ys = ws.dataY(i)
         ys -= 1000.0
     # The second fitting zone is wider.
     upperBkgIndices = [35, 36]
     for i in upperBkgIndices:
         ys = ws.dataY(i)
         ys += 5.0
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'BeamCentre': 30,
         'ForegroundHalfWidth': [1],
         'LowAngleBkgOffset': len(lowerExclusionIndices),
         'LowAngleBkgWidth': len(lowerBkgIndices),
         'HighAngleBkgOffset': len(upperExclusionIndices),
         'HighAngleBkgWidth': len(upperBkgIndices),
         'FluxNormalisation': 'Normalisation OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     for i in range(outWS.getNumberHistograms()):
         ys = outWS.readY(i)
         if i in lowerBkgIndices:
             numpy.testing.assert_equal(ys, 0)
         elif i in lowerExclusionIndices:
             numpy.testing.assert_equal(ys, -1005)
         elif i in foregroundIndices:
             numpy.testing.assert_equal(ys, 995)
         elif i in upperExclusionIndices:
             numpy.testing.assert_equal(ys, -1005)
         elif i in upperBkgIndices:
             numpy.testing.assert_equal(ys, 0)
         else:
             numpy.testing.assert_equal(ys, -5)
开发者ID:samueljackson92,项目名称:mantid,代码行数:60,代码来源:ReflectometryILLPreprocessTest.py


示例9: testAsymmetricForegroundRanges

 def testAsymmetricForegroundRanges(self):
     inWSName = 'ReflectometryILLPreprocess_test_ws'
     self.create_sample_workspace(inWSName)
     ws = mtd[inWSName]
     # Add special background fitting zones around the exclude zones.
     foregroundIndices = [21, 22, 23, 24]
     for i in range(ws.getNumberHistograms()):
         ys = ws.dataY(i)
         es = ws.dataE(i)
         if i in foregroundIndices:
             ys.fill(1000.0)
             es.fill(numpy.sqrt(1000.0))
         else:
             ys.fill(-100)
             es.fill(numpy.sqrt(100))
     args = {
         'InputWorkspace': inWSName,
         'OutputWorkspace': 'unused_for_child',
         'BeamCentre': 23,
         'ForegroundHalfWidth': [2, 1],
         'FlatBackground': 'Background OFF',
         'FluxNormalisation': 'Normalisation OFF',
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getNumberHistograms(), 100)
     logs = outWS.run()
     properties = ['foreground.first_workspace_index', 'foreground.centre_workspace_index', 'foreground.last_workspace_index']
     values = [21, 23, 24]
     for p, val in zip(properties, values):
         self.assertTrue(logs.hasProperty(p))
         self.assertEqual(logs.getProperty(p).value, val)
开发者ID:samueljackson92,项目名称:mantid,代码行数:35,代码来源:ReflectometryILLPreprocessTest.py


示例10: testSumInQModeProducesDX

 def testSumInQModeProducesDX(self):
     dirWS = illhelpers.create_poor_mans_d17_workspace()
     mtd.add('dirWS', dirWS)
     illhelpers.add_slit_configuration_D17(dirWS, 0.03, 0.02)
     illhelpers.add_chopper_configuration_D17(dirWS)
     illhelpers.refl_create_beam_position_ws('dirBeamPosWS', dirWS, 0., 128)
     dirWS = illhelpers.refl_preprocess('dirWS', dirWS, 'dirBeamPosWS')
     dirFgdWS = illhelpers.refl_sum_foreground('dirFgdWS', 'SumInLambda', dirWS)
     reflWS = illhelpers.create_poor_mans_d17_workspace()
     illhelpers.add_chopper_configuration_D17(reflWS)
     illhelpers.add_slit_configuration_D17(reflWS, 0.03, 0.02)
     illhelpers.refl_rotate_detector(reflWS, 1.5)
     mtd.add('reflWS', reflWS)
     illhelpers.refl_create_beam_position_ws('reflBeamPosWS', reflWS, 1.5, 128)
     reflWS = illhelpers.refl_preprocess('reflWS', reflWS, 'reflBeamPosWS')
     fgdWS = illhelpers.refl_sum_foreground('fgdWS', 'SumInQ', reflWS, dirFgdWS, dirWS)
     args = {
         'InputWorkspace': fgdWS,
         'OutputWorkspace': 'inQ',
         'DirectForegroundWorkspace': dirFgdWS,
         'GroupingQFraction': 0.2,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLConvertToQ', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEqual(outWS.getNumberHistograms(), 1)
     self.assertTrue(outWS.hasDx(0))
开发者ID:samueljackson92,项目名称:mantid,代码行数:29,代码来源:ReflectometryILLConvertToQTest.py


示例11: test_value_member_returns_python_list_for_multiple_files

 def test_value_member_returns_python_list_for_multiple_files(self):
     algorithm = create_algorithm('Load', Filename='MUSR15189,15190,15191.nxs',OutputWorkspace='w',
                               SpectrumMin=1,SpectrumMax=1,child=True)
     prop = algorithm.getProperty("Filename")
     filenames = prop.value
     self.assertTrue(isinstance(filenames, list))
     self.assertEquals(len(filenames), 3)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:MultipleFilePropertyTest.py


示例12: test_failure_X_out_of_bounds

 def test_failure_X_out_of_bounds(self):
     ws, unused, unused = self._make_single_histogram_ws()
     X = sys.float_info.max
     params = self._make_algorithm_params(ws, X)
     algorithm = testhelpers.create_algorithm('BinWidthAtX', **params)
     self.assertRaises(RuntimeError, algorithm.execute)
     self.assertFalse(algorithm.isExecuted())
     DeleteWorkspace(ws)
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:BinWidthAtXTest.py


示例13: test_value_member_returns_python_str_for_single_file

 def test_value_member_returns_python_str_for_single_file(self):
     algorithm = create_algorithm('Load', Filename='LOQ48127.raw',OutputWorkspace='w',
                               SpectrumMin=1,SpectrumMax=1,child=True)
     prop = algorithm.getProperty("Filename")
     filenames = prop.value
     self.assertTrue(isinstance(filenames, list))
     self.assertTrue(isinstance(filenames[0], str))
     self.assertEquals(len(filenames), 1)
开发者ID:DanNixon,项目名称:mantid,代码行数:8,代码来源:MultipleFilePropertyTest.py


示例14: _assert_run_algorithm_succeeds

 def _assert_run_algorithm_succeeds(self, args, expected):
     """Run the algorithm with the given args and check it succeeds, 
     and that the additional workspaces produced match the expected list.
     Clear these additional workspaces from the ADS"""
     alg = create_algorithm('ReflectometryISISLoadAndProcess', **args)
     assertRaisesNothing(self, alg.execute)
     actual = mtd.getObjectNames()
     self.assertEquals(set(actual), set(expected))
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:ReflectometryISISLoadAndProcessTest.py


示例15: refl_preprocess

def refl_preprocess(outputWSName, ws):
    args = {
        'InputWorkspace': ws,
        'OutputWorkspace': outputWSName,
    }
    alg = create_algorithm('ReflectometryILLPreprocess', **args)
    alg.execute()
    return mtd[outputWSName]
开发者ID:mantidproject,项目名称:mantid,代码行数:8,代码来源:illhelpers.py


示例16: _assert_run_algorithm_throws

 def _assert_run_algorithm_throws(self, args = {}):
     """Run the algorithm with the given args and check it throws"""
     throws = False
     alg = create_algorithm('ReflectometryISISLoadAndProcess', **args)
     try:
         alg.execute()
     except:
         throws = True
     self.assertEquals(throws, True)
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:ReflectometryISISLoadAndProcessTest.py


示例17: refl_preprocess_with_calibration

def refl_preprocess_with_calibration(outputWSName, ws, directLineWS):
    args = {
        'InputWorkspace': ws,
        'DirectLineWorkspace': directLineWS,
        'OutputWorkspace': outputWSName,
    }
    alg = create_algorithm('ReflectometryILLPreprocess', **args)
    alg.execute()
    return mtd[outputWSName]
开发者ID:mantidproject,项目名称:mantid,代码行数:9,代码来源:illhelpers.py


示例18: create_sample_workspace

 def create_sample_workspace(self, name, NumMonitors=0):
     args = {
         'OutputWorkspace': name,
         'Function': 'Flat background',
         'NumMonitors': NumMonitors,
         'NumBanks': 1,
     }
     alg = create_algorithm('CreateSampleWorkspace', **args)
     alg.setLogging(False)
     alg.execute()
开发者ID:samueljackson92,项目名称:mantid,代码行数:10,代码来源:ReflectometryILLPreprocessTest.py


示例19: refl_sum_foreground

def refl_sum_foreground(outputWSName, sumType, ws, dirFgdWS=None, dirWS=None):
    args = {
        'InputWorkspace': ws,
        'OutputWorkspace': outputWSName,
        'SummationType': sumType,
        'DirectForegroundWorkspace': dirFgdWS,
        'DirectBeamWorkspace': dirWS,
        'WavelengthRange': [0.1]
    }
    alg = create_algorithm('ReflectometryILLSumForeground', **args)
    alg.execute()
    return mtd[outputWSName]
开发者ID:samueljackson92,项目名称:mantid,代码行数:12,代码来源:illhelpers.py


示例20: testTwoInputFiles

 def testTwoInputFiles(self):
     outWSName = 'outWS'
     args = {
         'Run': 'ILL/D17/317369, ILL/D17/317370.nxs',
         'OutputWorkspace': outWSName,
         'rethrow': True,
         'child': True
     }
     alg = create_algorithm('ReflectometryILLPreprocess', **args)
     assertRaisesNothing(self, alg.execute)
     outWS = alg.getProperty('OutputWorkspace').value
     self.assertEquals(outWS.getAxis(0).getUnit().caption(), 'Wavelength')
开发者ID:samueljackson92,项目名称:mantid,代码行数:12,代码来源:ReflectometryILLPreprocessTest.py



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
Python testhelpers.run_algorithm函数代码示例发布时间:2022-05-27
下一篇:
Python testhelpers.assertRaisesNothing函数代码示例发布时间:2022-05-27
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap