How to use the underworld.function._function.Function.convert function in underworld

To help you get started, we’ve selected a few underworld examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github underworldcode / underworld2 / underworld / function / math.py View on Github external
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.Pow(self._fn1._fncself, self._fn2._fncself )
        # build parent
        super(pow,self).__init__(argument_fns=[fn1fn,fn2fn],**kwargs)
github underworldcode / underworld2 / underworld / function / exception.py View on Github external
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 )
github underworldcode / underworld2 / underworld / function / math.py View on Github external
def __init__(self, fn=None, *args, **kwargs):

        self._fn = _Function.convert(fn)

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

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

        # build parent
        super(cos,self).__init__(argument_fns=[fn,],**kwargs)
github underworldcode / underworld2 / underworld / function / tensor.py View on Github external
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_symmetric )

        # build parent
        super(symmetric,self).__init__(argument_fns=[fn,],**kwargs)
github underworldcode / underworld2 / underworld / function / math.py View on Github external
def __init__(self, fn=None, *args, **kwargs):

        self._fn = _Function.convert(fn)

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

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

        # build parent
        super(tanh,self).__init__(argument_fns=[fn,],**kwargs)
github underworldcode / underworld2 / underworld / function / exception.py View on Github external
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)
github underworldcode / underworld2 / underworld / systems / sle / _assemblyterm.py View on Github external
def fn_diffusivity(self, value):
        if not self._set_fn_diffusivity_function:
            raise RuntimeError("You cannot set a function for this assembly term.")
        _fn = uw.function._function.Function.convert(value)
        if not isinstance( _fn, uw.function.Function):
            raise ValueError( "Provided 'fn' must be of, or convertible to, 'Function' class." )
        self._fn_diffusivity = _fn
        self._set_fn_diffusivity_function( self._cself, self._fn_diffusivity._fncself )
github underworldcode / underworld2 / underworld / function / _function.py View on Github external
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.Relational_less(self._fn1._fncself, self._fn2._fncself )
        # build parent
        super(less,self).__init__(argument_fns=[fn1fn,fn2fn], **kwargs)
github underworldcode / underworld2 / underworld / function / view.py View on Github external
def __init__(self, fn, fn_norm=None, fn_auxiliary=None,  *args, **kwargs):

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

        fn_norm_cself = None
        if fn_norm:
            _fn_norm = _function.Function.convert(fn_norm)
            if _fn_norm == None:
                raise ValueError( "provided 'fn_norm' must a 'Function' or convertible.")
            self._fn_norm = _fn_norm
            fn_norm_cself = _fn_norm._fncself

        fn_auxiliary_cself = None
        if fn_auxiliary:
            _fn_auxiliary = _function.Function.convert(fn_auxiliary)
            if _fn_auxiliary == None:
github underworldcode / underworld2 / underworld / function / view.py View on Github external
_fn = _function.Function.convert(fn)
        if _fn == None:
            raise ValueError( "provided 'fn' must a 'Function' or convertible.")
        self._fn = _fn

        fn_norm_cself = None
        if fn_norm:
            _fn_norm = _function.Function.convert(fn_norm)
            if _fn_norm == None:
                raise ValueError( "provided 'fn_norm' must a 'Function' or convertible.")
            self._fn_norm = _fn_norm
            fn_norm_cself = _fn_norm._fncself

        fn_auxiliary_cself = None
        if fn_auxiliary:
            _fn_auxiliary = _function.Function.convert(fn_auxiliary)
            if _fn_auxiliary == None:
                raise ValueError( "provided 'fn_auxiliary' must a 'Function' or convertible.")
            self._fn_auxiliary = _fn_auxiliary
            fn_auxiliary_cself = _fn_auxiliary._fncself

        # create c instance
        self._fncself = _cfn.MinMax( self._fn._fncself, fn_norm_cself, fn_auxiliary_cself )

        # build parent
        super(min_max,self).__init__(argument_fns=[fn,],**kwargs)