本文整理汇总了Python中mantid.api.FunctionFactory.createInitialized方法的典型用法代码示例。如果您正苦于以下问题:Python FunctionFactory.createInitialized方法的具体用法?Python FunctionFactory.createInitialized怎么用?Python FunctionFactory.createInitialized使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.api.FunctionFactory
的用法示例。
在下文中一共展示了FunctionFactory.createInitialized方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: test_members_can_be_added
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createInitialized [as 别名]
def test_members_can_be_added(self):
func = CompositeFunction()
f1 = FunctionFactory.createInitialized('name=FlatBackground,A0=1')
f2 = FunctionFactory.createInitialized('name=FlatBackground,A0=2')
f3 = FunctionFactory.createInitialized('name=FlatBackground,A0=3')
func.add(f1)
func.add(f2)
func.add(f3)
self.assertEqual(len(func), 3)
self.assertEqual(str(func[0]), 'name=FlatBackground,A0=1')
self.assertEqual(str(func[1]), 'name=FlatBackground,A0=2')
self.assertEqual(str(func[2]), 'name=FlatBackground,A0=3')
示例2: initByName
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createInitialized [as 别名]
def initByName(self, name, *args, **kwargs):
"""
intialise composite function of named type.
E.g. "ProductFunction"
This function would be protected in c++
and should not be called directly except
by :meth:`__init__` functions of this class
and subclasses.
:param name: name of class calling this.
:param args: names of functions in composite function
:param kwargs: any parameters or attributes that must be passed to the
composite function itself.
"""
if len(args) == 1 and not isinstance(args[0], FunctionWrapper):
# We have a composite function to wrap
self.fun = args[0]
else:
self.fun = FunctionFactory.createCompositeFunction(name)
# Add the functions, checking for Composite & Product functions
for a in args:
if not isinstance(a, int):
if isinstance(a, CompositeFunctionWrapper):
if self.pureAddition:
self.pureAddition = a.pureAddition
if self.pureMultiplication:
self.pureMultiplication = a.pureMultiplication
functionToAdd = FunctionFactory.createInitialized(a.fun.__str__())
self.fun.add(functionToAdd)
self.init_paramgeters_and_attributes(**kwargs)
示例3: test_parameters_can_be_get_and_set
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createInitialized [as 别名]
def test_parameters_can_be_get_and_set(self):
func = FunctionFactory.createInitialized('name=FlatBackground,A0=1;name=FlatBackground,A0=2')
self.assertEqual(func.getParameterValue('f0.A0'), 1.0)
self.assertEqual(func.getParameterValue('f1.A0'), 2.0)
func.setParameter('f0.A0', 10.0)
self.assertEqual(func.getParameterValue('f0.A0'), 10.0)
func.setParameter('f1.A0', 20.0)
self.assertEqual(func.getParameterValue('f1.A0'), 20.0)
示例4: test_nested_functions
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createInitialized [as 别名]
def test_nested_functions(self):
s = 'name=FlatBackground,A0=1;(name=FlatBackground,A0=2;name=FlatBackground,A0=3)'
func = FunctionFactory.createInitialized(s)
self.assertEqual(len(func), 2)
self.assertFalse(isinstance(func[0], CompositeFunction))
self.assertTrue(isinstance(func[1], CompositeFunction))
self.assertEqual(len(func[1]), 2)
self.assertEqual(func.getParameterValue('f0.A0'), 1.0)
self.assertEqual(func.getParameterValue('f1.f0.A0'), 2.0)
self.assertEqual(func.getParameterValue('f1.f1.A0'), 3.0)
self.assertEqual(func.nParams(), 3)
示例5: test_instance_can_be_created_from_factory
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createInitialized [as 别名]
def test_instance_can_be_created_from_factory(self):
func = FunctionFactory.createInitialized('name=FlatBackground;name=FlatBackground')
self.assertTrue(isinstance(func, CompositeFunction))
self.assertEqual(len(func), 2)
self.assertEqual(func.nParams(), 2)