File: test_cell_uncompletion.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-- 614 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
import pytest
import itertools
from ase.cell import Cell


def all_pbcs():
    values = [False, True]
    yield from itertools.product(values, values, values)


@pytest.mark.parametrize('cell', [Cell.new([3, 4, 5]), Cell.new([2, 0, 3])])
def test_uncomplete(cell):
    for pbc in all_pbcs():
        ucell = cell.uncomplete(pbc)
        assert ucell.rank == sum(pbc & cell.any(1))

    assert all(cell.uncomplete(True).any(1) == cell.any(1)), (cell.uncomplete(True), cell)
    assert all(cell.uncomplete(1).any(1) == cell.any(1))
    assert cell.uncomplete(False).rank == 0
    assert cell.uncomplete(0).rank == 0