예제 #1
0
def test_Tensor_simplify():
    x, y, z = symbols("x y z")
    test_list = [[[x, y], [y, sin(2 * z) - 2 * sin(z) * cos(z)]], [[z ** 2, x], [y, z]]]
    obj = Tensor(test_list)
    # with set_self = False
    assert obj.simplify(set_self=False)[0, 1, 1] == 0
    assert not obj.tensor()[0, 1, 1] == 0
    # with set_self = True
    obj.simplify(set_self=True)
    assert obj.tensor()[0, 1, 1] == 0
예제 #2
0
def test_Tensor():
    x, y, z = symbols("x y z")
    test_list = [[[x, y], [y, sin(2 * z) - 2 * sin(z) * cos(z)]], [[z ** 2, x], [y, z]]]
    test_arr = Array(test_list)
    obj1 = Tensor(test_arr)
    obj2 = Tensor(test_list)
    assert obj1.tensor() == obj2.tensor()
    assert isinstance(obj1.tensor(), Array)
    assert obj1.simplify()[0, 1, 1] == 0