本文整理汇总了Python中mantid.api.FunctionFactory.createFunction方法的典型用法代码示例。如果您正苦于以下问题:Python FunctionFactory.createFunction方法的具体用法?Python FunctionFactory.createFunction怎么用?Python FunctionFactory.createFunction使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类mantid.api.FunctionFactory
的用法示例。
在下文中一共展示了FunctionFactory.createFunction方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: isregistered
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def isregistered(function):
status, msg = True, ""
try:
FunctionFactory.createFunction(function)
except RuntimeError as exc:
status, msg = False, 'Could not create {} function: {}'.format(function, str(exc))
return status, msg
示例2: is_registered
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def is_registered(function_name):
"""
Check whether the function with the specified name has been registered.
:param function_name: The name of the function to check for registration.
:return: A tuple of the status (True if function is registered,
false otherwise) and the error message (empty if the
function is registered).
"""
try:
FunctionFactory.createFunction(function_name)
except RuntimeError as exc:
return False, 'Could not create {} function: {}'.format(function_name,
str(exc))
return True, ""
示例3: create_mantid_ifunction
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def create_mantid_ifunction(self, function_name):
"""
Create and initiializes a Mantid IFunction.
Args:
function_name (str): The name of the function to use.
Returns:
ifunction: An instance of a Mantid IFunction
"""
from mantid.api import FunctionFactory
return FunctionFactory.createFunction(function_name)
示例4: __init__
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def __init__(self, name, **kwargs):
"""
Called when creating an instance
:param name: name of fitting function to create or
an Ifunction object to wrap.
:param kwargs: standard argument for initializing fit
function
"""
if not isinstance(name, str):
self.fun = name
else:
self.fun = FunctionFactory.createFunction(name)
self.init_paramgeters_and_attributes(**kwargs)
示例5: test_get_Gaussian
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_get_Gaussian(self):
name = "Gaussian"
func = FunctionFactory.createFunction(name)
self.assertTrue(func.name() == name)
self.assertTrue(len(func.__repr__()) > len(name))
self.assertTrue("Peak" in func.categories())
示例6: test_addition
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_addition(self):
p = FunctionFactory.createFunction("ProductFunction")
g = FunctionFactory.createFunction("Gaussian")
p.add(g)
p.add(g)
self.assertEquals(len(p), 2)
示例7: test_length
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_length(self):
p = FunctionFactory.createFunction("ProductFunction")
self.assertEquals(len(p), 0)
示例8: test_type
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_type(self):
p = FunctionFactory.createFunction("ProductFunction")
self.assertTrue( isinstance(p,ProductFunction) )
self.assertTrue( isinstance(p,CompositeFunction) )
示例9: test_category_override_returns_overridden_result
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_category_override_returns_overridden_result(self):
FunctionFactory.subscribe(Times2)
func = FunctionFactory.createFunction("Times2")
self.assertEquals("SimpleFunction", func.category())
FunctionFactory.unsubscribe("Times2")
示例10: test_category_with_no_override_returns_default_category
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_category_with_no_override_returns_default_category(self):
FunctionFactory.subscribe(NoCatgeoryFunction)
func = FunctionFactory.createFunction("NoCatgeoryFunction")
self.assertEquals("General", func.category())
FunctionFactory.unsubscribe("NoCatgeoryFunction")
示例11: test_instance_can_be_created_from_factory
# 需要导入模块: from mantid.api import FunctionFactory [as 别名]
# 或者: from mantid.api.FunctionFactory import createFunction [as 别名]
def test_instance_can_be_created_from_factory(self):
FunctionFactory.subscribe(Times2)
func_name = Times2.__name__
func = FunctionFactory.createFunction(func_name)
self.assertTrue(isinstance(func, IFunction1D))
FunctionFactory.unsubscribe(func_name)