本文整理汇总了Python中_function.Function.convert方法的典型用法代码示例。如果您正苦于以下问题:Python Function.convert方法的具体用法?Python Function.convert怎么用?Python Function.convert使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类_function.Function
的用法示例。
在下文中一共展示了Function.convert方法的8个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, clauses, *args, **kwargs):
# error check mapping
if not isinstance(clauses, (list,tuple)):
raise TypeError("'clauses' object passed in must be of python type 'list' or 'tuple'")
self._clauses = []
funcSet = set()
for clause in clauses:
if not isinstance(clause, (list,tuple)):
raise TypeError("Clauses within the clause list must be of python type 'list' or 'tuple'")
if len(clause) != 2:
raise ValueError("Clauses tuples must be of length 2.")
conditionFn = _Function.convert(clause[0])
funcSet.add(conditionFn)
resultantFn = _Function.convert(clause[1])
funcSet.add(resultantFn)
self._clauses.append( (conditionFn,resultantFn) )
# build parent
self._fncself = _cfn.Conditional()
super(conditional,self).__init__(argument_fns=funcSet,**kwargs)
# insert clause into c object now
for clause in self._clauses:
self._fncself.insert( clause[0]._fncself, clause[1]._fncself )
示例2: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn_stress, fn_stresslimit, fn_inputviscosity, *args, **kwargs):
_fn_stress = _Function.convert(fn_stress)
if _fn_stress == None:
raise ValueError( "Provided 'fn_stress' must a 'Function' or convertible type.")
self._fn_stress = _fn_stress
_fn_stresslimit = _Function.convert(fn_stresslimit)
if _fn_stresslimit == None:
raise ValueError( "Provided 'fn_stresslimit' must a 'Function' or convertible type.")
self._fn_stresslimit = _fn_stresslimit
_fn_inputviscosity = _Function.convert(fn_inputviscosity)
if _fn_inputviscosity == None:
raise ValueError( "Provided 'fn_inputviscosity' must a 'Function' or convertible type.")
self._fn_inputviscosity = _fn_inputviscosity
# grab second inv of stress
secondInvFn = _tensor.second_invariant(self._fn_stress)
# create conditional
self._conditional = _branching.conditional( [ ( secondInvFn > _fn_stresslimit , fn_inputviscosity*_fn_stresslimit/secondInvFn ), # if over limit, reduce viscosity
( True , fn_inputviscosity ) ] ) # else return viscosity
# this function is not based on a c function itself, so instead point the c pointer to the conditionals.
self._fncself = self._conditional._fncself
# build parent
super(stress_limiting_viscosity,self).__init__(argument_fns=[_fn_stress,_fn_stresslimit,_fn_inputviscosity],**kwargs)
示例3: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn_input, fn_condition, fn_print=None, *args, **kwargs):
_fn_input = _Function.convert(fn_input)
if _fn_input == None:
raise ValueError( "provided 'fn_input' must a 'Function' or convertible.")
self._fn_input = _fn_input
_fn_condition = _Function.convert(fn_condition)
if _fn_condition == None:
raise ValueError( "provided 'fn_condition' must a 'Function' or convertible.")
self._fn_condition = _fn_condition
if fn_print != None:
_fn_print = _Function.convert(fn_print)
if _fn_print == None:
raise ValueError( "provided 'fn_print' must a 'Function' or convertible.")
self._fn_print = _fn_print
# create instance
if not fn_print:
self._fncself = _cfn.CustomException( self._fn_input._fncself, self._fn_condition._fncself )
else:
self._fncself = _cfn.CustomException( self._fn_input._fncself, self._fn_condition._fncself, self._fn_print._fncself )
# build parent
# note that we only pass in _fn_input as the argument_fns, as _fn_condition & _fn_print are
# not dynamically relevant... it is only used for performing the exception check.
super(CustomException,self).__init__(argument_fns=[_fn_input,],**kwargs)
示例4: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn1, fn2, **kwargs):
fn1fn = _Function.convert( fn1 )
if not isinstance( fn1fn, _Function ):
raise TypeError("Functions must be of type (or convertible to) 'Function'.")
fn2fn = _Function.convert( fn2 )
if not isinstance( fn2fn, _Function ):
raise TypeError("Functions must be of type (or convertible to) 'Function'.")
self._fn1 = fn1fn
self._fn2 = fn2fn
# ok finally lets create the fn
self._fncself = _cfn.Min(self._fn1._fncself, self._fn2._fncself )
# build parent
super(min,self).__init__(argument_fns=[fn1fn,fn2fn],**kwargs)
示例5: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, vertices, fn=None, *args, **kwargs):
if fn:
self._fn = _Function.convert(fn)
else:
self._fn = input()
if not isinstance(vertices, _np.ndarray):
raise TypeError( "Provided 'vertices' must be a numpy array." )
if len(vertices.shape) != 2:
raise TypeError( "Provided 'vertices' array must be 2 dimensional." )
if vertices.shape[0] < 3:
raise TypeError( "Provided 'vertices' array must contain at least 3 vertices." )
if vertices.shape[1] != 2:
raise TypeError( "Provided 'vertices' array must contain 2d vectors." )
# ok, need to create a 3d array from the 2d array.. create array of required size
threedeearray = _np.zeros( (vertices.shape[0],3) )
# now copy
threedeearray[:,0:2] = vertices[:,0:2]
# create instance
import random
import string
self._id = "".join(random.choice(string.ascii_uppercase + string.digits) for _ in range(8))
self._fncself = _cfn.Polygon( self._fn._fncself, threedeearray, self._id )
# build parent
super(Polygon,self).__init__(argument_fns=[fn,], *args, **kwargs)
示例6: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn1, fn2, **kwargs):
# lets convert integer powers to floats
if isinstance(fn2, int):
fn2 = float(fn2)
fn1fn = _Function.convert( fn1 )
if not isinstance( fn1fn, _Function ):
raise TypeError("Functions must be of type (or convertible to) 'Function'.")
fn2fn = _Function.convert( fn2 )
if not isinstance( fn2fn, _Function ):
raise TypeError("Functions must be of type (or convertible to) 'Function'.")
self._fn1 = fn1fn
self._fn2 = fn2fn
# ok finally lets create the fn
self._fncself = _cfn.MathBinary(self._fn1._fncself, self._fn2._fncself, _cfn.MathBinary.pow )
# build parent
super(pow,self).__init__(argument_fns=[fn1fn,fn2fn],**kwargs)
示例7: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.MinMax( self._fn._fncself )
# build parent
super(min_max,self).__init__(argument_fns=[fn,],**kwargs)
示例8: __init__
# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import convert [as 别名]
def __init__(self, fn, *args, **kwargs):
_fn = _Function.convert(fn)
if _fn == None:
raise ValueError( "provided 'fn' must a 'Function' or convertible.")
self._fn = _fn
# create instance
self._fncself = _cfn.TensorFunc( self._fn._fncself, _cfn.TensorFunc.get_antisymmetric )
# build parent
super(antisymmetric,self).__init__(argument_fns=[fn,],**kwargs)