コード例 #1
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __init__(self, low, high, leaf=None):
        """*low* is the Function giving the lower boundary, *high* gives the
        upper boundary, and *leaf* is the Function to be clipped."""

        self.low = asfunction(low)
        self.high = asfunction(high)
        self.leaf = asfunction(leaf)
コード例 #2
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
def compound(obj):
    """Replaces lists, tuples, dicts, constants in *obj* by corresponding 
    Functions.

    *   lists are replaced by :class:`_List` instances.
    *   tuples are replaced by :class:`_Tuple` instances.
    *   dicts are replaced by :class:`_Dict` instances.
    *   Other objects are passed through :func:`asfunction`.
    
    Use this method to generate Functions out of lists, tuples, or
    dictionary composed of other Functions."""

    if isinstance(obj, list):
        return _List([compound(element) for element in obj])
    elif isinstance(obj, tuple):
        return _Tuple([compound(element) for element in obj])
    elif isinstance(obj, dict):
        keys = [compound(key) for key in obj.keys()]
        values = [compound(value) for value in obj.values()]
        return _Dict(dict(zip(keys, values)))
    else:
        return asfunction(obj)
コード例 #3
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __rpow__(self, base):
        """Raises the other Function to the power of ``self``."""

        base = asfunction(base)
        return Power(base=base, exponent=self)
コード例 #4
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __pow__(self, exponent):
        """Raises ``self`` to the power of the other Function."""

        exponent = asfunction(exponent)
        return Power(base=self, exponent=exponent)
コード例 #5
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __rdiv__(self, other):
        """Returns the :class:`Quotient` of the other Function with 
        ``self``."""

        other = asfunction(other)
        return Quotient(other, self)
コード例 #6
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __div__(self, other):
        """Returns the :class:`Quotient` with the other Function."""

        other = asfunction(other)
        return Quotient(self, other)
コード例 #7
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __rmul__(self, other):
        """Returns the :class:`Product` of the other Function with 
        ``self``."""

        other = asfunction(other)
        return Product(other, self)
コード例 #8
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
 def __init__(self, base, exponent):
     
     self.base = asfunction(base)
     self.exponent = asfunction(exponent)
コード例 #9
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __mul__(self, other):
        """Returns the :class:`Product` with the other Function."""

        other = asfunction(other)
        return Product(self, other)
コード例 #10
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
 def __init__(self, value, low, high):
     
     self.value = asfunction(value)
     self.low = asfunction(low)
     self.high = asfunction(high)
コード例 #11
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
 def __init__(self, A, B):
     
     self.A = asfunction(A)
     self.B = asfunction(B)
コード例 #12
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __rsub__(self, other):
        """Returns the :class:`Sum` of the other Function with the negative of
        ``self``."""

        other = asfunction(other)
        return Sum(other, -self)
コード例 #13
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
 def __init__(self, one, two):
     
     self.one = asfunction(one)
     self.two = asfunction(two)
コード例 #14
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __sub__(self, other):
        """Returns the :class:`Sum` with the negative of the other 
        Function."""

        other = asfunction(other)
        return Sum(self, Neg(other))
コード例 #15
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __radd__(self, other):
        """Returns the :class:`Sum` with another Function."""

        other = asfunction(other)
        return Sum(other, self)
コード例 #16
0
ファイル: op.py プロジェクト: friedrichromstedt/fframework
    def __init__(self, a, b):
        """*b* will be executed with the output of *a* as input."""

        self.a = asfunction(a)
        self.b = asfunction(b)