File: test_info.py

package info (click to toggle)
python-ase 3.26.0-2
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 15,484 kB
  • sloc: python: 148,112; xml: 2,728; makefile: 110; javascript: 47
file content (26 lines) | stat: -rw-r--r-- 703 bytes parent folder | download
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
26
# fmt: off
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