File: test_poscar.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 (32 lines) | stat: -rw-r--r-- 817 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
27
28
29
30
31
32
# fmt: off
# import inspect
from shutil import copyfile

import numpy as np
import pytest

# from ase import Atoms
from ase.io import read  # , iread


@pytest.fixture()
def outcar(datadir):
    return datadir / 'vasp' / 'OUTCAR_example_1'


@pytest.fixture()
def poscar_no_species(datadir):
    return datadir / 'vasp' / 'POSCAR_example_1'


def test_read_poscar_no_species(outcar, poscar_no_species, tmp_path):
    copyfile(outcar, tmp_path / 'OUTCAR')
    copyfile(poscar_no_species, tmp_path / 'POSCAR')

    at_outcar = read(outcar)
    at_poscar = read(tmp_path / 'POSCAR')

    assert len(at_outcar) == len(at_poscar)
    assert np.all(np.isclose(at_outcar.cell, at_poscar.cell))
    assert np.all(np.isclose(at_outcar.positions, at_poscar.positions))
    assert np.all(at_outcar.numbers == at_poscar.numbers)