File: test_nomad.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 (32 lines) | stat: -rw-r--r-- 927 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
21
22
23
24
25
26
27
28
29
30
31
32
# Stripped (minimal) version of nomad entry with 3 images.
# The images are actually identical for some reason, but we want to be sure
# that they are extracted correctly.


def test_nomad(datadir):
    from ase.io import iread

    path = datadir / 'nomad-images.nomad-json'
    images = list(iread(path))
    assert len(images) == 3

    for atoms in images:
        assert all(atoms.pbc)
        assert (atoms.cell > 0).sum() == 3
        assert atoms.get_chemical_formula() == 'As24Sr32'


# Code for cleaning up nomad files so their size is reasonable for inclusion
# in test suite:
"""
ourkeys = {'section_run', 'section_system', 'name', 'atom_species',
           'atom_positions', 'flatData', 'uri', 'gIndex',
           'configuration_periodic_dimensions', 'lattice_vectors'}

includekeys = lambda k: k in ourkeys

fname = ...
with open(fname) as fd:
    d = read(fd, includekeys=includekeys)
print(json.dumps(d))
"""