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


Python Function._CheckIsFnOrConvertOrThrow方法代码示例

本文整理汇总了Python中_function.Function._CheckIsFnOrConvertOrThrow方法的典型用法代码示例。如果您正苦于以下问题:Python Function._CheckIsFnOrConvertOrThrow方法的具体用法?Python Function._CheckIsFnOrConvertOrThrow怎么用?Python Function._CheckIsFnOrConvertOrThrow使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在_function.Function的用法示例。


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

示例1: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [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._CheckIsFnOrConvertOrThrow(clause[0])
            funcSet.add(conditionFn)
            actionFn    = _Function._CheckIsFnOrConvertOrThrow(clause[1])
            funcSet.add(actionFn)
            self._clauses.append( (conditionFn,actionFn) )
        
        # 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 )
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:28,代码来源:branching.py

示例2: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
 def __init__(self, fn1, fn2, **kwargs):
     fn1fn = _Function._CheckIsFnOrConvertOrThrow( fn1 )
     if not isinstance( fn1fn, _Function ):
         raise TypeError("Functions must be of type (or convertible to) 'Function'.")
     fn2fn = _Function._CheckIsFnOrConvertOrThrow( 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.fmin )
     # build parent
     super(min,self).__init__(argument_fns=[fn1fn,fn2fn],**kwargs)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:16,代码来源:misc.py

示例3: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
    def __init__(self, vertices, fn=None, *args, **kwargs):

        if fn:
            self._fn = _Function._CheckIsFnOrConvertOrThrow(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)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:31,代码来源:shape.py

示例4: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
    def __init__(self, fn, *args, **kwargs):

        _fn = _Function._CheckIsFnOrConvertOrThrow(fn)
        if _fn == None:
            raise ValueError( "provided 'fn' must a 'Function' or convertible.")
        self._fn = _fn

        # create instance
        self._fncself = _cfn.SafeMaths( self._fn._fncself )

        # build parent
        super(SafeMaths,self).__init__(argument_fns=[_fn,],**kwargs)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:14,代码来源:exception.py

示例5: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
    def __init__(self, fn, *args, **kwargs):

        _fn = _Function._CheckIsFnOrConvertOrThrow(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.second_invariant )

        # build parent
        super(second_invariant,self).__init__(argument_fns=[fn,],**kwargs)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:14,代码来源:tensor.py

示例6: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
    def __init__(self, fn=None, *args, **kwargs):

        self._fn = _Function._CheckIsFnOrConvertOrThrow(fn)

        fncself = None
        if self._fn:
            fncself = self._fn._fncself

        # create instance
        self._fncself = _cfn.MathUnary_sin( fncself )

        # build parent
        super(sin,self).__init__(argument_fns=[fn,],**kwargs)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:15,代码来源:_math.py

示例7: __init__

# 需要导入模块: from _function import Function [as 别名]
# 或者: from _function.Function import _CheckIsFnOrConvertOrThrow [as 别名]
    def __init__(self, fn_stress, fn_stresslimit, fn_inputviscosity, stressFn=None, stressLimitFn=None, inputViscosityFn=None, *args, **kwargs):

        # DEPRECATE 1/16
        if stressFn:
            raise RuntimeError("Note that the 'stressFn' parameter has been renamed to 'fn_stress'.")
        if stressLimitFn:
            raise RuntimeError("Note that the 'stressLimitFn' parameter has been renamed to 'fn_stresslimit'.")
        if inputViscosityFn:
            raise RuntimeError("Note that the 'inputViscosityFn' parameter has been renamed to 'fn_inputviscosity'.")

        _fn_stress = _Function._CheckIsFnOrConvertOrThrow(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._CheckIsFnOrConvertOrThrow(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._CheckIsFnOrConvertOrThrow(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)
开发者ID:AngelValverdePerez,项目名称:underworld2,代码行数:39,代码来源:rheology.py


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