def test_symbol_values(): ga = GA(2, [1., 1.]) assert ga._0 == ga.MV([0.0, 0.0, 0.0, 0.0]) assert ga._1 == ga.MV([1.0, 0.0, 0.0, 0.0]) assert ga.e1 == ga.MV([0.0, 1.0, 0.0, 0.0]) assert ga.e2 == ga.MV([0.0, 0.0, 1.0, 0.0]) assert ga.I == ga.MV([0.0, 0.0, 0.0, 1.0]) assert ga.e12 == ga.MV([0.0, 0.0, 0.0, 1.0])
def test_format(): ga = GA(3) doctest(ga.MV([0., -0., 0., -0., 0., -0., 0., -0.]), '0.0') doctest( ga.MV([1., -1., 1., -1., 1., -1., 1., -1.]), '1.0-e1+e2-e3+e12-e13+e23-I', ) doctest(ga.MV([2., -2., 2., -2., 2., -2., 2., -2.]), '2.0-2.0e1+2.0e2-2.0e3+2.0e12-2.0e13+2.0e23-2.0I')
def test_itp(): ga = GA(3) x = ga.MV([1., 2., 3., 4., 5., 6., 7., 8.]) assert tuple(x.itp(-1)) == () assert tuple(x.itp(0)) == (1.0, ) assert tuple(x.itp(1)) == (2.0, 3.0, 4.0)
def test_part(): ga = GA(3) x = ga.MV([1., 2., 3., 4., 5., 6., 7., 8.]) doctest(x.part(-1), '0.0') doctest(x.part(0), '1.0') doctest(x.part(1), '2.0e1+3.0e2+4.0e3') doctest(x.part(2), '5.0e12+6.0e13+7.0e23') doctest(x.part(3), '8.0I') doctest(x.part(4), '0.0')
def test_one(): ga = GA(0) assert ga.one() == ga.MV([1.0])
def test_zero(): ga = GA(0) assert ga.zero() == ga.MV([0.0])
def test_repr(): ga = GA(2) x = ga.MV([1., 2., 3., 4.]) assert repr(x) == 'MV([1.0, 2.0, 3.0, 4.0])'