File: test_cfg.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 (20 lines) | stat: -rw-r--r-- 455 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
def test_cfg():
    import numpy as np

    from ase.build import molecule
    from ase.io import read, write

    a = molecule('CO2')
    f = np.array([[1, 2, 3], [4, 5, 6], [7, 8, 9]])
    a.set_array('test', f)

    write('test.cfg', a)

    b = read('test.cfg')
    assert np.all(b.get_array('test') == f)

    a.set_momenta(2 * f)
    write('test.cfg', a)

    b = read('test.cfg')
    assert np.all(np.abs(a.get_momenta() - b.get_momenta()) < 1e-3)