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_helpers_and_coordinate_dependent(): one_form = R2.dr + R2.dx two_form = Differential(R2.x * R2.dr + R2.r * R2.dx) three_form = Differential(R2.y * two_form) + Differential( R2.x * Differential(R2.r * R2.dr)) metric = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dy, R2.dy) metric_ambig = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dr, R2.dr) misform_a = TensorProduct(R2.dr, R2.dr) + R2.dr misform_b = R2.dr**4 misform_c = R2.dx * R2.dy twoform_not_sym = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dx, R2.dy) twoform_not_TP = WedgeProduct(R2.dx, R2.dy) assert covariant_order(one_form) == 1 assert covariant_order(two_form) == 2 assert covariant_order(three_form) == 3 assert covariant_order(two_form + metric) == 2 assert covariant_order(two_form + metric_ambig) == 2 assert covariant_order(two_form + twoform_not_sym) == 2 assert covariant_order(two_form + twoform_not_TP) == 2 pytest.raises(ValueError, lambda: covariant_order(misform_a)) pytest.raises(ValueError, lambda: covariant_order(misform_b)) pytest.raises(ValueError, lambda: covariant_order(misform_c)) assert twoform_to_matrix(metric) == Matrix([[1, 0], [0, 1]]) assert twoform_to_matrix(twoform_not_sym) == Matrix([[1, 0], [1, 0]]) assert twoform_to_matrix(twoform_not_TP) == Matrix([[0, -1], [1, 0]]) pytest.raises(ValueError, lambda: twoform_to_matrix(one_form)) pytest.raises(ValueError, lambda: twoform_to_matrix(three_form)) pytest.raises(ValueError, lambda: twoform_to_matrix(metric_ambig)) pytest.raises(ValueError, lambda: metric_to_Christoffel_1st(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Christoffel_2nd(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Riemann_components(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Ricci_components(twoform_not_sym))
def test_helpers_and_coordinate_dependent(): one_form = R2.dr + R2.dx two_form = Differential(R2.x*R2.dr + R2.r*R2.dx) three_form = Differential( R2.y*two_form) + Differential(R2.x*Differential(R2.r*R2.dr)) metric = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dy, R2.dy) metric_ambig = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dr, R2.dr) misform_a = TensorProduct(R2.dr, R2.dr) + R2.dr misform_b = R2.dr**4 misform_c = R2.dx*R2.dy twoform_not_sym = TensorProduct(R2.dx, R2.dx) + TensorProduct(R2.dx, R2.dy) twoform_not_TP = WedgeProduct(R2.dx, R2.dy) assert covariant_order(one_form) == 1 assert covariant_order(two_form) == 2 assert covariant_order(three_form) == 3 assert covariant_order(two_form + metric) == 2 assert covariant_order(two_form + metric_ambig) == 2 assert covariant_order(two_form + twoform_not_sym) == 2 assert covariant_order(two_form + twoform_not_TP) == 2 pytest.raises(ValueError, lambda: covariant_order(misform_a)) pytest.raises(ValueError, lambda: covariant_order(misform_b)) pytest.raises(ValueError, lambda: covariant_order(misform_c)) assert twoform_to_matrix(metric) == Matrix([[1, 0], [0, 1]]) assert twoform_to_matrix(twoform_not_sym) == Matrix([[1, 0], [1, 0]]) assert twoform_to_matrix(twoform_not_TP) == Matrix([[0, -1], [1, 0]]) pytest.raises(ValueError, lambda: twoform_to_matrix(one_form)) pytest.raises(ValueError, lambda: twoform_to_matrix(three_form)) pytest.raises(ValueError, lambda: twoform_to_matrix(metric_ambig)) pytest.raises(ValueError, lambda: metric_to_Christoffel_1st(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Christoffel_2nd(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Riemann_components(twoform_not_sym)) pytest.raises(ValueError, lambda: metric_to_Ricci_components(twoform_not_sym))