Composed Functions, in the case that they do not belong to the moviemaker2 framework (but are rather abstract functions, belonging to the Function framework):
from moviemaker2.function import asfunction
from moviemaker2.math.primitive import MathFunction
class Sum(MathFunction):
def __init__(self, one, two):
self.one = asfunction(one)
self.two = asfunction(two)
def __call__(self, *args, **kwargs):
return self.one(*args, **kwargs) + self.two(*args, **kwargs)
If they are moviemaker2 specific Functions:
class PlaneWave(MathFunction):
def __init__(self, Y, X, wavevector):
self.Y = asfunction(Y)
self.X = asfunction(X)
self.wavevector = asfunction(wavevector)
def __call__(self, ps):
Y = self.Y(ps)
X = self.X(ps)
wavevector = self.wavevector(ps)
return (asarray([Y, X]) * wavevector).sum(axis=0)
Following guidelines: