moviemaker2.math.primitive
The primitive arithmetic operations must be overloaded in the class definition
directly, and therefore the returned Functions are defined in this module too,
and not in moviemaker.math where they belong to. Nevertheless they
will be available through the moviemaker.math module, too.
-
class moviemaker2.math.primitive.MathFunction(wrap)[source]
Supports overloaded primitve arithmetics. Can wrap an ordinary
Function, to extend it by math overloads.
Examples: (fXXX is a function for something “XXX”)
- fa + fb, etc.
- numpy.cos(fangle). This works through the cos() method.
Same for numpy.sin(fangle).
- numpy.sum(farray, axis=1). This works through the sum()
method.
-
__init__(wrap)[source]
wrap is an ordinary Function, being used during __call__.
-
__call__(*args, **kwargs)[source]
Calls just .wrap.
-
__add__(other)[source]
Returns the Sum with another Function.
-
__radd__(other)[source]
Returns the Sum with another Function.
-
__sub__(other)[source]
Returns the Sum with the negative of the other
Function.
-
__rsub__(other)[source]
Returns the Sum of the other Function with the negative of
self.
-
__mul__(other)[source]
Returns the Product with the other Function.
-
__rmul__(other)[source]
Returns the Product of the other Function with
self.
-
__div__(other)[source]
Returns the Quotient with the other Function.
-
__rdiv__(other)[source]
Returns the Quotient of the other Function with
self.
-
__pow__(exponent)[source]
Raises self to the power of the other Function.
-
__rpow__(base)[source]
Raises the other Function to the power of self.
-
__pos__()[source]
Returns self.
-
__neg__()[source]
Returns the Nagative of self.
-
sin()[source]
Takes the sine.
-
cos()[source]
Takes the cosine.
-
exp()[source]
Exponentiates.
-
sum(*args, **kwargs)[source]
Returns a Sum of self with the arguments for calling
.sum() given by the arguments given here.
-
clip(low, high)[source]
Returns a Clip instance of self with low and high
set up.
-
astype(*args, **kwargs)[source]
Returns a asarray instance of self with args and
kwargs handed over. Can be used for converting to other dtypes:
func.astype(dtype=numpy.int)
-
__getitem__(index)[source]
Returns a Indexing instance of self with index set
up.
-
__or__(other)[source]
Piping is composition of Functions. The pipe operator is designed
such that the wrapping function is written last: other will be
executed with the ouput of self as input.
-
class moviemaker2.math.primitive.MathComposedFunction(a, b)[source]
Executes one function with the output of another.
-
__init__(a, b)[source]
b will be executed with the output of a as input.
-
__call__(*args, **kwargs)[source]
Returns b(a(...)).
-
class moviemaker2.math.primitive.MathConstant(value)[source]
Constant, extended by mathematical
overloads.
-
class moviemaker2.math.primitive.MathIdentity[source]
Identity, extended by mathatical
overloads.
-
moviemaker2.math.primitive.asmathfunction(mathfunction_like)[source]
- If mathfunction_like is a MathFunction, it is returned
unchanged.
- If mathfunction_like is a Function,
MathFunction(mathfunction_like) is returned.
- If function_like is None, a MathIdentity is returned.
- Else, the function_like is interpreted as a MathConstant.
For asmathfunctionv(), asmathfunction() is applied on any element
of an array_like argument.
-
moviemaker2.math.primitive.asmathfunctionv(pyfunc, otypes='', doc=None)
- If mathfunction_like is a MathFunction, it is returned
unchanged.
- If mathfunction_like is a Function,
MathFunction(mathfunction_like) is returned.
- If function_like is None, a MathIdentity is returned.
- Else, the function_like is interpreted as a MathConstant.
For asmathfunctionv(), asmathfunction() is applied on any element
of an array_like argument.
-
class moviemaker2.math.primitive.Sum(one, two)[source]
Abstract sum Function.
-
__init__(one, two)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Product(one, two)[source]
Abstract product Function.
-
__init__(one, two)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Quotient(one, two)[source]
Abstract quotient Function.
-
__init__(one, two)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Cmp(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Less(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Greater(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.LessEqual(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.GreaterEqual(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Equal(A, B)[source]
Abstract comparison Function.
-
__init__(A, B)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Not(A)[source]
Abstract comparison Function.
-
__init__(A)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Power(base, exponent)[source]
Abstract power Function.
-
__init__(base, exponent)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Neg(invertible)[source]
Abstract negative Function.
-
__init__(invertible)[source]
-
__call__(*args, **kwargs)[source]
-
class moviemaker2.math.primitive.Cos(angle=None)[source]
Takes the cosine.
-
__init__(angle=None)[source]
The value of angle is in radians.
-
__call__(*args, **kwargs)[source]
Calculates the cosine of the value of angle using
numpy.cos.
-
class moviemaker2.math.primitive.Sin(angle=None)[source]
Takes the sine.
-
__init__(angle=None)[source]
The value of angle is in radians.
-
__call__(*args, **kwargs)[source]
Calculates the sine of the value of angle using
numpy.sin.
-
class moviemaker2.math.primitive.Exp(exponent=None)[source]
Exponentiates.
-
__init__(exponent=None)[source]
exponent is used as the argument to numpy.exp().
-
__call__(*args, **kwargs)[source]
Calculates exp() of .exponent().
-
class moviemaker2.math.primitive.SumCall(array, *sum_args, **sum_kwargs)[source]
Calles .sum() with predefined arguments. This is intended for
use with ndarray-values Functions.
-
__init__(array, *sum_args, **sum_kwargs)[source]
The value of array must have a .sum method. The sum() method
will be called on call time with the arguments and kwargs given.
-
__call__(*args, **kwargs)[source]
Calls array with the arguments, and then calls .sum() on
the value with the arguments defined at initialisation time.
-
class moviemaker2.math.primitive.Indexing(index, items=None)[source]
Returns an item from the value of another Function.
Examples:
- Indexing of a tuple with an integer.
- Indexing of a ndarray with any index accepted by the ndarray.
- Indexing of a dictionary.
The index is static, i.e., it isn’t a Function.
-
__init__(index, items=None)[source]
items returns the items the Indexing chooses from. The value
of items must support indexing.
index might be any index accepted by the value of items.
-
__call__(*args, **kwargs)[source]
Indexes the value of items with index.
-
class moviemaker2.math.primitive.AttributeAccess(attribute, host=None)[source]
Returns an attribute from the value of another Function.
-
__init__(attribute, host=None)[source]
host is the Function with values hosting the attribute named
attribute.
-
__call__(*args, **kwargs)[source]
Returns the attribute attribute from the value of host.
-
class moviemaker2.math.primitive.Clip(low, high, leaf=None)[source]
Clips the leaf Function’s value.
-
__init__(low, high, leaf=None)[source]
low is the Function giving the lower boundary, high gives the
upper boundary, and leaf is the Function to be clipped.
-
__call__(*args, **kwargs)[source]
Calls .low(), .high(), .leaf(), and clips using the
values.