File: test_atoms_indices.py

package info (click to toggle)
python-ase 3.24.0-1
  • links: PTS, VCS
  • area: main
  • in suites: trixie
  • size: 15,448 kB
  • sloc: python: 144,945; xml: 2,728; makefile: 113; javascript: 47
file content (18 lines) | stat: -rw-r--r-- 379 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
import numpy as np

from ase import Atoms


def test_species_index():

    a = Atoms(['H', 'H', 'C', 'C', 'H'])

    spind = a.symbols.species_indices()

    assert (np.array(spind) == [0, 1, 0, 1, 2]).all()

    # It should work as the inverse to this
    allind = a.symbols.indices()

    for i, s in enumerate(a.symbols):
        assert (list(allind[s]).index(i) == spind[i])