def test_Molecule_repr_is_implemented(self):
     m = core.Molecule('AMMONIA')
     m.add(core.Atom(1, "N", 0.257, -0.363, 0.0))
     m.add(core.Atom(2, "H", 0.257, 0.727, 0.0))
     m.add(core.Atom(3, "H", 0.771, -0.727, 0.890))
     m.add(core.Atom(4, "H", 0.771, -0.727, -0.890))
     assert repr(m) == ('Molecule("AMMONIA", '
                        '(Atom(1, "N", 0.257, -0.363, 0.0), '
                        'Atom(2, "H", 0.257, 0.727, 0.0), '
                        'Atom(3, "H", 0.771, -0.727, 0.89), '
                        'Atom(4, "H", 0.771, -0.727, -0.89)))')
 def test_Molecule_str_is_implemented(self):
     m = core.Molecule('AMMONIA')
     m.add(core.Atom(1, "N", 0.257, -0.363, 0.0))
     m.add(core.Atom(2, "H", 0.257, 0.727, 0.0))
     m.add(core.Atom(3, "H", 0.771, -0.727, 0.890))
     m.add(core.Atom(4, "H", 0.771, -0.727, -0.890))
     assert str(m) == ('(AMMONIA, '
                       '((N, 0.257, -0.363, 0.0), '
                       '(H, 0.257, 0.727, 0.0), '
                       '(H, 0.771, -0.727, 0.89), '
                       '(H, 0.771, -0.727, -0.89)))')
Example #3
0
def partition(n, coll):
    _x_, _r_, recur, _zz_ = None, None, None, std.Atom("!")

    ###
    def _f_(ret, arg):
        if notEmpty(arg[0]): ret.append(arg[0])
        return ret if 0 == count(arg[1]) else recur(ret, splitSeq(arg[1], n))

    _r_ = _f_

    def _loop(*xs):
        nonlocal _x_, _r_, _zz_
        _x_ = xs
        if not (_r_ is _zz_):
            _r_ = _zz_
            while _r_ is _zz_:
                _r_ = _f_(*_x_)
            return _r_
        return _zz_

    recur = _loop
    if isSequential(coll):
        return recur(toPair(), splitSeq(coll, n))
    elif not coll:
        return toPair()
    else:
        throwE(f"Cannot partition with: {rtti(coll)}")
 def test_Atom_init_is_implemented(self):
     atom = core.Atom(1, 2, 3, 4, 5)
     assert atom.number == 1
     assert atom.center == (3, 4, 5)
     assert atom.symbol == 2
 def test_add_is_implemented(self):
     atom = core.Atom(1, 'N', 0.257, -0.363, 0.000)
     m = core.Molecule('AMMONIA')
     m.add(atom)
     assert m.atoms == [atom]
 def test_Atom_translate_is_implemented(self):
     atom = core.Atom(1, 2, 3, 4, 5)
     atom.translate(1, 2, 3)
     assert atom.center == (4, 6, 8)
 def test_Atom_repr_is_implemented(self):
     atom = core.Atom(1, 2, 3, 4, 5)
     assert repr(atom) == 'Atom(1, "2", 3, 4, 5)'
 def test_Atom_str_is_implemented(self):
     atom = core.Atom(1, 2, 3, 4, 5)
     assert str(atom) == '(2, 3, 4, 5)'