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


Python FunctionFactory.createInitialized方法代码示例

本文整理汇总了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')
开发者ID:DanNixon,项目名称:mantid,代码行数:14,代码来源:CompositeFunctionTest.py

示例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)
开发者ID:mantidproject,项目名称:mantid,代码行数:33,代码来源:fitfunctions.py

示例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)
开发者ID:DanNixon,项目名称:mantid,代码行数:10,代码来源:CompositeFunctionTest.py

示例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)
开发者ID:DanNixon,项目名称:mantid,代码行数:13,代码来源:CompositeFunctionTest.py

示例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)
开发者ID:DanNixon,项目名称:mantid,代码行数:7,代码来源:CompositeFunctionTest.py


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