moviemaker2.math

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”)

  1. fa + fb, etc.
  2. numpy.cos(fangle). This works through the cos() method. Same for numpy.sin(fangle).
  3. 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:

  1. Indexing of a tuple with an integer.
  2. Indexing of a ndarray with any index accepted by the ndarray.
  3. 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.

moviemaker2.math.polar

Provides conversion between polar and cartesian coordinates.

class moviemaker2.math.polar.Polar2DtoCartesian2D(r, phi)[source]

Computes cartesian 2D coordinates from 2D polar coordinates.

__init__(r, phi)[source]

r and phi are the polar coordinates.

__call__(*args, **kwargs)[source]

Calculates the cartesian coordinates from the polar coordinates. The result of r and phi must be of compatible shape.

Return a ndarray [y, x].

class moviemaker2.math.polar.Cartesian2DtoPolar2D(y, x)[source]

Calculates 2D polar coordinates from 2D cartesian coordinates.

__init__(y, x)[source]

x and y are the cartesian coordinates.

__call__(*args, **kwargs)[source]

Calculates the polar coordaintes from the cartesian coordinates.

The value of x and y must at least be of compatible shape.

The angle is calculates mathematically positive starting in the direction os +x with phi=0.

Returns a ndarray [r, phi]

moviemaker2.math.interpolate

class moviemaker2.math.interpolate.Interp(xp, fp, x, left=None, right=None)[source]

The pendant to numpy.interp().

__init__(xp, fp, x, left=None, right=None)[source]

Arguments are like for numpy.interp(). If left or right is None, None is handed over to numpy.interp() in __call__ (i.e., None is not interpreted as the identity Function).

__call__(*args, **kwargs)[source]

Calls numpy.interp() with .xp(), .fp(), .left(), .right().

class moviemaker2.math.interpolate.Spline(points, progress)[source]

Carries out spline interpolation.

__init__(points, progress)[source]

points is a sequence of points of the spline. progress is the real-valued [0, 1] progress value of the spline.

__call__(*args, **kwargs)[source]

Spline-interpolates the result of .points() at the position .progress().

moviemaker2.math.polynomial

class moviemaker2.math.polynomial.Polynomial(coefficients, x=None, null=None)[source]

Implements polynomials with Functions a coefficients and argument.

__init__(coefficients, x=None, null=None)[source]

coefficients gives the coefficients of the polynomial. x gives the argument of the polynomial. null is the null with respect to +, and None means ordinary 0.0.

__call__(*args, **kwargs)[source]

Returns the polynomial specified by .coefficients() at the position .x().

Table Of Contents

Previous topic

moviemaker2.function

Next topic

moviemaker2.parameter

This Page