def test_correct_arguments(): pytest.raises(ValueError, lambda: R2.e_x(R2.e_x)) pytest.raises(ValueError, lambda: R2.e_x(R2.dx)) pytest.raises(ValueError, lambda: Commutator(R2.e_x, R2.x)) pytest.raises(ValueError, lambda: Commutator(R2.dx, R2.e_x)) pytest.raises(ValueError, lambda: Differential(Differential(R2.e_x))) pytest.raises(ValueError, lambda: R2.dx(R2.x)) pytest.raises(ValueError, lambda: TensorProduct(R2.e_x, R2.dx)) pytest.raises(ValueError, lambda: LieDerivative(R2.dx, R2.dx)) pytest.raises(ValueError, lambda: LieDerivative(R2.x, R2.dx)) pytest.raises(ValueError, lambda: CovarDerivativeOp(R2.dx, [])) pytest.raises(ValueError, lambda: CovarDerivativeOp(R2.x, [])) a = Symbol('a') pytest.raises(ValueError, lambda: intcurve_series(R2.dx, a, R2_r.point([1, 2]))) pytest.raises(ValueError, lambda: intcurve_series(R2.x, a, R2_r.point([1, 2]))) pytest.raises(ValueError, lambda: intcurve_diffequ(R2.dx, a, R2_r.point([1, 2]))) pytest.raises(ValueError, lambda: intcurve_diffequ(R2.x, a, R2_r.point([1, 2]))) pytest.raises(ValueError, lambda: contravariant_order(R2.e_x + R2.dx)) pytest.raises(ValueError, lambda: contravariant_order(R2.dx**2)) pytest.raises(ValueError, lambda: covariant_order(R2.e_x + R2.dx)) pytest.raises(ValueError, lambda: contravariant_order(R2.e_x*R2.e_y)) pytest.raises(ValueError, lambda: covariant_order(R2.dx*R2.dy)) assert covariant_order(Integer(0), True) == -1 assert contravariant_order(Integer(0), True) == -1
def test_lie_derivative(): assert LieDerivative(R2.e_x, R2.y) == R2.e_x(R2.y) == 0 assert LieDerivative(R2.e_x, R2.x) == R2.e_x(R2.x) == 1 assert LieDerivative(R2.e_x, R2.e_x) == Commutator(R2.e_x, R2.e_x) == 0 assert LieDerivative(R2.e_x, R2.e_r) == Commutator(R2.e_x, R2.e_r) assert LieDerivative(R2.e_x + R2.e_y, R2.x) == 1 assert LieDerivative(R2.e_x, TensorProduct(R2.dx, R2.dy))(R2.e_x, R2.e_y) == 0
def test_commutator(): assert Commutator(R2.e_x, R2.e_y) == 0 assert Commutator(R2.x * R2.e_x, R2.x * R2.e_x) == 0 assert Commutator(R2.x * R2.e_x, R2.x * R2.e_y) == R2.x * R2.e_y c = Commutator(R2.e_x, R2.e_r) assert c(R2.x) == R2.y * (R2.x**2 + R2.y**2)**(-1) * sin(R2.theta)