Esempio n. 1
0
def test_Spacegroup():
    transgen = geo.canonical
    c1 = geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), transgen)
    c2 = geo.Coset(
        geo.Symmetry(
            nb.Matrix([[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0],
                       [0, 0, 0, 1]])), transgen)
    sg = geo.Spacegroup(transgen, [c1, c2])
    assert sg.__str__() == \
        "Spacegroup        \n"\
        "----------        \n"\
        " canonical        \n"\
        "             x,y,z\n"\
        "          -x,-y,-z"
    transgen = geo.Transgen(geo.Dif(nb.Matrix([[1], [0], [0], [0]])),
                            geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                            geo.Dif(nb.Matrix([[0], [0], [2], [0]])))
    c1 = geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), transgen)
    c2 = geo.Coset(
        geo.Symmetry(
            nb.Matrix([[-1, 0, 0, 0], [0, -1, 0, 0], [0, 0, -1, 0],
                       [0, 0, 0, 1]])), transgen)
    sg = geo.Spacegroup(transgen, [c1, c2])
    assert sg.__str__() == \
        "                           Spacegroup        \n"\
        "                           ----------        \n"\
        "Transgen /  1  \   /  0  \   /  0  \         \n"\
        "        |   0   | |   1   | |   0   |        \n"\
        "         \  0  /   \  0  /   \  2  /         \n"\
        "                                        x,y,z\n"\
        "                                     -x,-y,-z"

    sg = geo.Spacegroup(geo.canonical, [
        geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), geo.canonical),
        geo.Coset(
            geo.Symmetry(
                nb.Matrix([[1, 0, 0, 0], [0, -1, 0, 0], [0, 0, 1, 0],
                           [0, 0, 0, 1]])), geo.canonical)
    ])

    transformation = geo.Transformation(
        nb.Matrix([[0, 1, 0, 0], [1, 0, 0, 0], [0, 0, 1, 0], [0, 0, 0, 1]]))
    sg1 = transformation**sg
    sg2 = geo.Spacegroup(transformation**geo.canonical, [
        geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), geo.canonical),
        geo.Coset(
            geo.Symmetry(
                nb.Matrix([[-1, 0, 0, 0], [0, 1, 0, 0], [0, 0, 1, 0],
                           [0, 0, 0, 1]])), geo.canonical)
    ])

    assert sg.is_really_a_spacegroup() == True
    sg_error = geo.Spacegroup(geo.canonical, [
        geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), geo.canonical),
        geo.Coset(
            geo.Symmetry(
                nb.Matrix([[1, 0, 0, fr.Fraction(1, 4)], [0, 1, 0, 0],
                           [0, 0, 1, 0], [0, 0, 0, 1]])), geo.canonical)
    ])
    assert sg_error.is_really_a_spacegroup() == False
Esempio n. 2
0
def test_Coset():
    g = geo.Symmetry(nb.Matrix([[1,  0, 2, -1],
                                [0, -2, 0,  0],
                                [0,  0, 1,  1],
                                [0,  0, 0,  1]]))
    tg = geo.Transgen(geo.Dif(nb.Matrix([[1], [0], [0], [0]])),
                      geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                      geo.Dif(nb.Matrix([[0], [0], [2], [0]])))
    tg1 = geo.Transgen(geo.Dif(nb.Matrix([[1], [0], [0], [0]])),
                       geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                       geo.Dif(nb.Matrix([[0], [0], [2], [0]])))
    assert tg == tg1
    c = geo.Coset(g, tg)
    assert c.__str__() == \
        "{x+2z,-2y,z+1}\n"\
        "     1  0  0  \n"\
        "     0  1  0  \n"\
        "     0  0  2  "
    c = geo.Coset(g, geo.canonical)
    assert c.__str__() == "{x+2z,-2y,z}"
    g = geo.Symmetry(nb.Matrix([[ 1, 0, 0, 0.5],
                                [ 0, 1, 0, 0],
                                [ 0, 0, 1, 0],
                                [ 0, 0, 0, 1]]))
    c = geo.Coset(g, geo.canonical)
    g2 = geo.Symmetry(nb.Matrix([[ 1, 0, 0, -0.5],
                                 [ 0, 1, 0, 0],
                                 [ 0, 0, 1, 0],
                                 [ 0, 0, 0, 1]]))
    p1 = geo.Pos(nb.Matrix([[0.3], [0], [0], [1]]))
    p2 = geo.Pos(nb.Matrix([[0.8], [0], [0], [1]]))
    assert c.coset_representant_for_pos(p1) == g
    assert c.coset_representant_for_pos(p2) == g2
Esempio n. 3
0
def test_Symmetry():
    g = geo.Symmetry(
        nb.Matrix([[1, 0, 2, -1], [0, -2, 0, 0], [0, 0, 1,
                                                  fr.Fraction(1, 3)],
                   [0, 0, 0, 1]]))
    assert g.__str__() == "x+2z-1,-2y,z+1/3"

    assert isinstance(g.inv(), geo.Symmetry)
    assert g * g.inv() == geo.Symmetry(nb.Matrix.onematrix(4))
Esempio n. 4
0
def test_Dif():
    x = geo.Dif(nb.Matrix([[1], [2], [3], [0]]))
    assert x.__str__() == "Dif /  1  \ \n   |   2   |\n    \  3  / "
    assert x.x() == 1
    assert x.y() == 2
    assert x.z() == 3
    assert x.to_Symmetry() == geo.Symmetry(
        nb.Matrix([[1, 0, 0, 1], [0, 1, 0, 2], [0, 0, 1, 3], [0, 0, 0, 1]]))
Esempio n. 5
0
def test_Symmetry():
    g = geo.Symmetry(nb.Matrix([[1,  0, 2, -1],
                                [0, -2, 0,  0],
                                [0,  0, 1,  fr.Fraction(1, 3)],
                                [0,  0, 0,  1]]))
    assert g.__str__() == "x+2z-1,-2y,z+1/3"

    assert isinstance(g.inv(), geo.Symmetry)
    assert g * g.inv() == geo.Symmetry(nb.Matrix.onematrix(4))

    g = geo.Symmetry(nb.Matrix([[0,-1, 0, 0],
                                [1, -1,  0, 0],
                                [0,  0,  1, 0],
                                [0,  0,  0, 1]]))
    print(g)
    assert g.__str__() == "-y,x-y,z"
    x = uc.ufloat(0.4, 0.1)
    p = geo.Pos(nb.Matrix([[x], [x], [0], [1]]))
    print(p)
    print((g*g*g)**p)
    assert (g*g*g)**p == p
Esempio n. 6
0
def symmetryfromstr(string):
    words = string.split(',')
    assert len(words) == 3, \
        "The following string looks like a Symmetry, but it has not "\
        "three comma-separated terms: %s" % (string)
    liste = []
    for word in words:
        row = nb.Row(str2linearterm(word, ['x', 'y', 'z']))
        liste.append(row)
    liste.append(
        nb.Row([fromstr("0"),
                fromstr("0"),
                fromstr("0"),
                fromstr("1")]))
    return geo.Symmetry(nb.Matrix(liste))
Esempio n. 7
0
def test_operations():
    # Here I want to test all operations between equal and different types.
    # It shall be as follows:
    #
    #         *         | Symmetry    Transformation   Transgen   Coset  Pos Dif Metric  Spacegroup
    # ----------------------------------------------------------------------------------------------
    #   Symmetry        | Symmetry         -              -         -     -   -    -          -
    #   Transformation  |    -        Transformation      -         -     -   -    -          -
    #   Transgen        |    -             -              -         -     -   -    -          -
    #   Coset           |    -             -              -       Coset   -   -    -          -
    #   Pos             |    -             -              -         -     -   -    -          -
    #   Dif             |    -             -              -         -     -   -    -          -
    #   Metric          |    -             -              -         -     -   -    -          -
    #   Spacegroup      |    -             -              -         -     -   -    -          -
    #
    #
    #         **        | Symmetry  Transformation  Transgen  Coset    Pos   Dif Metric  Spacegroup
    # -----------------------------------------------------------------------------------------------
    #   Symmetry        |    -             -           -        -      Pos   Dif   -         -
    #   Transformation  | Symmetry         -        Transgen  Coset    Pos   Dif Metric  Spacegroup
    #   Transgen        |    -             -           -        -       -     -    -         -
    #   Coset           |    -             -           -        -      Pos   Dif   -         -
    #   Pos             |    -             -           -        -       -     -    -         -
    #   Dif             |    -             -           -        -       -     -    -         -
    #   Metric          |    -             -           -        -       -     -    -         -
    #   Spacegroup      |    -             -           -        -       -     -    -         -
    #
    #
    #         %         | Symmetry  Transformation   Transgen  Coset   Pos   Dif Metric  Spacegroup
    #  ---------------------------------------------------------------------------------------------
    #   Symmetry        |    -            -          Symmetry    -      -     -    -         -
    #   Transformation  |    -            -             -        -      -     -    -         -
    #   Transgen        |    -            -             -        -      -     -    -         -
    #   Coset           |    -            -           Coset      -      -     -    -         -
    #   Pos             |    -            -            Pos       -      -     -    -         -
    #   Dif             |    -            -            Dif       -      -     -    -         -
    #   Metric          |    -            -             -        -      -     -    -         -
    #   Spacegroup      |    -            -          Spacegroup  -      -     -    -         -

    # Coset needs some pow()-declarations, so first I test everything else:
    symmetry = geo.Symmetry(nb.Matrix([[-1,  0, 0, 0],
                                       [0, -1, 0, 0],
                                       [0,  0, 1, 0],
                                       [0,  0, 0, 1]]))
    transformation = geo.Transformation(nb.Matrix([[0, 1, 0, 0],
                                                   [1, 0, 0, 0],
                                                   [0, 0, 2, 0],
                                                   [0, 0, 0, 1]]))
    transgen = geo.canonical
    pos = geo.Pos(nb.Matrix([[1], [2], [3], [1]]))
    dif = geo.Dif(nb.Matrix([[4], [5], [6], [0]]))
    metric = geo.Metric(nb.Matrix([[4, 0, 0, 0],
                                   [0, 9, 0, 0],
                                   [0, 0, 1, 0],
                                   [0, 0, 0, 1]]))
    spacegroup = geo.Spacegroup(geo.canonical,
        [geo.Coset(geo.Symmetry(nb.Matrix.onematrix(4)), geo.canonical),
         geo.Coset(geo.Symmetry(nb.Matrix([[-1,  0,  0, 0],
                                           [0, -1,  0, 0],
                                           [0,  0, -1, 0],
                                           [0,  0,  0, 1]])), geo.canonical)])

    # * :
    #====

    # symmetry * symmetry:
    assert isinstance(symmetry * symmetry, geo.Symmetry)

    # transformation * transformation
    assert isinstance(transformation * transformation, geo.Transformation)

    # **:
    #====

    # symmetry ** pos:
    assert isinstance(symmetry ** pos, geo.Pos)

    # symmetry ** dif:
    assert isinstance(symmetry ** dif, geo.Dif)

    # transformation ** symmetry:
    assert isinstance(transformation ** symmetry, geo.Symmetry)

    # transformation ** transgen:
    assert isinstance(transformation ** transgen, geo.Transgen)

    # transformation ** pos:
    assert isinstance(transformation ** pos, geo.Pos)

    # transformation ** dif:
    assert isinstance(transformation ** dif, geo.Dif)

    # transformation ** metric:
    assert isinstance(transformation ** metric, geo.Metric)

    # transformation ** spacegroup:
    assert isinstance(transformation ** spacegroup, geo.Spacegroup)

    # %:
    #===

    # symmetry % transgen:
    assert isinstance(symmetry % transgen, geo.Symmetry)

    # pos % transgen:
    assert isinstance(pos % transgen, geo.Pos)
    transgen1 = geo.Transgen(geo.Dif(nb.Matrix([[1], [0], [0], [0]])),
                             geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                             geo.Dif(nb.Matrix([[0], [0], [2], [0]])))
    pos1 = geo.Pos(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [1]]))
    pos1_ = geo.Pos(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [1]]))
    assert pos1 % transgen1 == pos1_

    transgen1 = geo.Transgen(geo.Dif(nb.Matrix([[0], [0], [2], [0]])),
                             geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                             geo.Dif(nb.Matrix([[1], [0], [0], [0]])))
    pos1 = geo.Pos(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [1]]))
    pos1_ = geo.Pos(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [1]]))
    assert pos1 % transgen1 == pos1_

    # dif % transgen:
    assert isinstance(dif % transgen, geo.Dif)

    transgen1 = geo.Transgen(geo.Dif(nb.Matrix([[0], [0], [2], [0]])),
                             geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                             geo.Dif(nb.Matrix([[1], [0], [0], [0]])))
    dif1 = geo.Dif(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [0]]))
    dif1_ = geo.Dif(nb.Matrix([[0], [0], [fr.Fraction(3, 2)], [0]]))
    assert dif1 % transgen1 == dif1_

    # spacegroup % transgen:
    assert isinstance(spacegroup % transgen, geo.Spacegroup)

    # Here comes Coset:
    #==================

    coset = geo.Coset(symmetry, transgen)

    # coset * coset:
    assert isinstance(coset * coset, geo.Coset)

    # coset ** pos:
    assert isinstance(coset ** pos, geo.Pos)

    # coset ** dif:
    assert isinstance(coset ** dif, geo.Dif)

    # coset % transgen:
    assert isinstance(coset % transgen, geo.Coset)

    transgen1 = geo.Transgen(geo.Dif(nb.Matrix([[0], [0], [2], [0]])),
                             geo.Dif(nb.Matrix([[0], [1], [0], [0]])),
                             geo.Dif(nb.Matrix([[1], [0], [0], [0]])))
    coset1 = geo.Coset(geo.Symmetry(nb.Matrix([[1, 0, 0, fr.Fraction(3, 2)],
                                               [0, 1, 0, fr.Fraction(3, 2)],
                                               [0, 0, 1, fr.Fraction(7, 2)],
                                               [0, 0, 0, 1]])), transgen1)
    coset1_ = geo.Coset(geo.Symmetry(nb.Matrix([[1, 0, 0, fr.Fraction(1, 2)],
                                                [0, 1, 0, fr.Fraction(1, 2)],
                                                [0, 0, 1, fr.Fraction(3, 2)],
                                                [0, 0, 0, 1]])), transgen1)
    assert coset1 % transgen1 == coset1_
Esempio n. 8
0
def test_Pointgroup():
    pg = geo.Pointgroup([geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                 [0, 1, 0, 0],
                                                 [0, 0, 1, 0],
                                                 [0, 0, 0, 1]])),
                         geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                 [0, -1, 0, 0],
                                                 [0, 0, -1, 0],
                                                 [0, 0, 0, 1]]))])

    assert isinstance(pg, geo.Pointgroup)
    assert pg.__str__() == "Pointgroup\n" \
                           "==========\n" \
                           "x,y,z\n" \
                           "-x,-y,-z\n"

    assert pg.is_really_a_pointgroup()

    pg1 = geo.Pointgroup([geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                 [0, 1, 0, 0],
                                                 [0, 0, 1, 0],
                                                 [0, 0, 0, 1]])),
                         geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                 [0, -1, 0, 0],
                                                 [0, 0, -1, 0],
                                                 [0, 0, 0, 1]]))])

    pg2 = geo.Pointgroup([geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                  [0, -1, 0, 0],
                                                  [0, 0, -1, 0],
                                                  [0, 0, 0, 1]]))])

    assert pg == pg1
    assert not (pg == pg2)
    assert not (pg == 2)

    assert not pg2.is_really_a_pointgroup()

    G = geo.Pointgroup([geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]]))])

    assert G.is_really_a_pointgroup()

    g = G.liste
    # For this test, the order of the symmetry elements must not be
    # completely arbitrary, because there are several valid possibilities
    # to sort the symmetryelements.
    G1 = geo.Pointgroup([g[6], g[7], g[0], g[14], g[15], g[9], g[10], g[11],
                         g[12], g[13], g[8], g[1], g[2], g[3], g[4], g[5]])

    print(G1.sort())
    print(G)
    assert G1.sort() == G

    H = geo.Pointgroup([geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, 1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[-1, 0, 0, 0],
                                                [0, -1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[1, 0, 0, 0],
                                                [0, 1, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, 1, 0, 0],
                                                [-1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]])),
                        geo.Symmetry(nb.Matrix([[0, -1, 0, 0],
                                                [1, 0, 0, 0],
                                                [0, 0, -1, 0],
                                                [0, 0, 0, 1]]))])

    assert H.is_really_a_pointgroup()
    assert G1.coset_decomposition_with_respect_to(H) \
        == "x,y,z\n" \
           "-x,y,-z\n"
Esempio n. 9
0
def test_fromstr():
    string = "1/2"
    assert isinstance(fs(string), nb.Mixed)
    assert fs(string) == nb.Mixed(fr.Fraction(1, 2))
    string = "1.2+/-0.1"
    assert fs(string).value.n == nb.Mixed(uc.ufloat(1.2, 0.1)).value.n
    assert fs(string).value.s == nb.Mixed(uc.ufloat(1.2, 0.1)).value.s
    string = "1.2(1)"
    assert fs(string).value.n == nb.Mixed(uc.ufloat(1.2, 0.1)).value.n
    assert fs(string).value.s == nb.Mixed(uc.ufloat(1.2, 0.1)).value.s
    string = "4"
    assert fs(string) == nb.Mixed(fr.Fraction(4, 1))
    string = "4.5"
    assert fs(string) == nb.Mixed(4.5)

    string = "1 2 3"
    assert fromstr.typefromstr(string) == nb.Matrix
    assert fs(string) == nb.Matrix([[1, 2, 3]])

    string = "/ 1 2 \ \n \ 3 4 /"
    assert fs(string) == \
        nb.Matrix([nb.Row([nb.Mixed(1), nb.Mixed(2)]),
                   nb.Row([nb.Mixed(3), nb.Mixed(4)])])
    string = "1 2 \n 3 4"
    assert fs(string) == \
        nb.Matrix([nb.Row([nb.Mixed(1), nb.Mixed(2)]),
                   nb.Row([nb.Mixed(3), nb.Mixed(4)])])
    string = "x+y,y - x +1/3,2z"
    g = fs(string)
    assert g == geo.Symmetry(
        fs("/ 1 1 0 0 \n"
           " -1 1 0 1/3 \n"
           "  0 0 2 0 \n"
           "  0 0 0 1"))
    string = "O->(0,0,0)\n" \
             "then\n" \
             "a' = a-b \n" \
             "b' = b+a \n" \
             "c' = 2c"
    g = fs(string)
    assert g == geo.Transformation(
        fs(" 1 1 0 0 \n"
           "-1 1 0 0 \n"
           " 0 0 2 0 \n"
           " 0 0 0 1").inv())

    string = "O->(0,0,0) \n" \
             "then\n" \
             "a' = c \n" \
             "b' = a \n" \
             "c' = b"
    g = fs(string)
    assert g == geo.Transformation(
        fs("0 1 0 0 \n"
           "0 0 1 0 \n"
           "1 0 0 0 \n"
           "0 0 0 1").inv())
    string = "O -> (1/2, 0, 0) \n" \
             "then\n" \
             "a' = a \n" \
             "b' = b \n" \
             "c' = c"
    g = fs(string)
    assert g == geo.Transformation(
        fs("1 0 0 -1/2 \n"
           "0 1 0    0 \n"
           "0 0 1    0 \n"
           "0 0 0    1"))

    string1 = "O -> (1/2, 0, 0) \n" \
              "then\n" \
              "a' = a \n" \
              "b' = b \n" \
              "c' = c"

    string2 = "O -> (0,0,0) \n" \
              "then\n" \
              "a' = b\n" \
              "b' = a\n" \
              "c' = c"
    string = "O -> (1/2, 0, 0) \n" \
             "then\n"\
             "a' = b\n"\
             "b' = a\n"\
             "c' = c"

    g1 = fs(string1)
    g2 = fs(string2)
    g = fs(string)
    assert g == g2 * g1

    string = "O -> (1/2, 0, 0) \n" \
             "then\n" \
             "a' = a + b\n" \
             "b' = b\n" \
             "c' = c"
    print("--------")
    g = fs(string)
    print(g.value)
    assert g**fs("p 1/2 0 0") == fs("p 0 0 0")
    assert g**fs("p 1/2 1/3 0") == fs("p 0 1/3 0")
    assert g**fs("p 0 0 0") == fs("p -1/2 1/2 0")

    assert g * g.inv() == geo.Transformation(nb.Matrix.onematrix(4))

    string = "p0 0 0"
    p = fs(string)
    assert p == geo.Pos(fs("0 \n 0 \n 0 \n 1"))
    string = "P0 0 0"
    p = fs(string)
    assert p == geo.Pos(fs("0 \n 0 \n 0 \n 1"))
    string = "r0 0 0"
    p = fs(string)
    assert p == geo.Pos(fs("0 \n 0 \n 0 \n 1"))
    string = "R0 0 0"
    p = fs(string)
    assert p == geo.Pos(fs("0 \n 0 \n 0 \n 1"))
    string = p.__str__()
    assert string == "Pos /  0  \ \n" \
                     "   |   0   |\n" \
                     "    \  0  / "
    p1 = fs(string)
    assert p == p1
    string = "R1/2 1/2 1/2"
    p = fs(string)
    assert p == geo.Pos(fs("1/2 \n 1/2 \n 1/2 \n 1"))

    q = fs("k1 2 3")
    assert q == geo.Rec(fs("1 2 3 0"))
    q = fs("K 1 2 3")
    assert q == geo.Rec(fs("1 2 3 0"))
    q = fs("q 1/2 1/2 0")
    assert q == geo.Rec(fs("1/2 1/2 0 0"))
    q = fs("Q0 0 0")
    assert q == geo.Rec(fs("0 0 0 0"))
    q = fs("Rec <  1  2  3  > ")
    assert q == geo.Rec(fs("1 2 3 0"))