def __init__(self, dir, name=None): super().__init__(ScalarShape()) self._dir = dir if name == None: self._name = Expr._dirName(dir) else: self._name = name
def _getShape(x): '''Return the shape of the argument x. ''' if isinstance(x, Expr): return x.shape() elif isinstance(x, Number): return ScalarShape() raise ValueError('Expr._getShape() got bad arg [{}]'.format(x))
class ScalarBasisBase: _shape = ScalarShape() def __init__(self): pass def shape(self): return ScalarBasisBase._shape
def outputShape(self, input): if isinstance(input, (VectorShape, VectorShape)): return ScalarShape() if isinstance(input, TensorShape): return VectorShape(input.dim()) raise ValueError( 'Div.outputShape expected vector or tensor, got [{}]'.format( input))
def test_Rot(self): x = Coordinate(0) y = Coordinate(1) rot = _Rot() F = Vector(x, y) rotF = rot(F) print('Rot(F)=', rotF) assert (rotF.sameas(DiffOp(rot, F)) and rotF.shape() == ScalarShape())
def test_Div(self): x = Coordinate(0) y = Coordinate(1) div = _Div() F = Vector(x, y) divF = Div(F) print('Div(F)=', divF) assert (divF.sameas(DiffOp(div, F)) and divF.shape() == ScalarShape())
def __init__(self, parent, myIndex): super().__init__(ScalarShape()) super(Expr, self).__init__(parent, myIndex)
def __init__(self, data): super().__init__(data, ScalarShape())
def __init__(self, L, R): super().__init__(L, R, ScalarShape())
def outputShape(self, input): assert (self.acceptShape(input)) return ScalarShape()
def __init__(self, y, x): super().__init__(y, x, ScalarShape())