File: test_info.py

package info (click to toggle)
python-ase 3.21.1-2
  • links: PTS, VCS
  • area: main
  • in suites: bullseye
  • size: 13,936 kB
  • sloc: python: 122,428; xml: 946; makefile: 111; javascript: 47
file content (25 lines) | stat: -rw-r--r-- 692 bytes parent folder | download | duplicates (3)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
from ase import Atoms
from ase.io import Trajectory


def test_atoms_info_in_traj():
    info = dict(creation_date='2011-06-27',
                chemical_name='Hydrogen',
                # custom classes also works provided that it is
                # imported and pickleable...
                foo={'seven': 7})

    molecule = Atoms('H2', positions=[(0., 0., 0.), (0., 0., 1.1)], info=info)
    assert molecule.info == info

    atoms = molecule.copy()
    assert atoms.info == info

    with Trajectory('info.traj', 'w', atoms=molecule) as traj:
        traj.write()

    with Trajectory('info.traj') as traj:
        atoms = traj[-1]

    print(atoms.info)
    assert atoms.info == info