def __init__(self, name, arg): assert (Expr._convertibleToExpr(arg)) expr = Expr._convertToExpr(arg) if not isinstance(expr.shape(), ScalarShape): raise ValueError( 'UnivariateFuncExpr ctor: non-scalar arg [{}]'.format(expr)) super().__init__(expr, expr.shape()) self._name = name
def __call__(self, arg): # Make sure the type makes sense if not Expr._convertibleToExpr(arg): raise TypeError('diff op [{}] cannot accept type [{}]'.format( self, arg)) f = Expr._convertToExpr(arg) # Make sure the operator and input are consistent if not self.acceptShape(f.shape()): raise TypeError('diff op [{}] cannot accept argument [{}]'.format( self, f)) # Form the diff op expression if isinstance(f, SymbolicFunctionBase): return DiffOpOnFunction(self, f) return DiffOp(self, f)