File: test_negativeindex.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 (19 lines) | stat: -rw-r--r-- 505 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
# fmt: off
from ase.atoms import Atoms
from ase.constraints import FixScaled


def test_negativeindex():
    a1 = Atoms(symbols='X2',
               positions=[[0., 0., 0.], [2., 0., 0.]],
               cell=[[4., 0., 0.], [0., 4., 0.], [0., 0., 4.]])

    fs1 = FixScaled(-1, mask=(True, False, False))
    fs2 = FixScaled(1, mask=(False, True, False))

    a1.set_constraint([fs1, fs2])

    # reassigning using atoms.__getitem__
    a2 = a1[0:2]

    assert len(a1.constraints) == len(a2.constraints)