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

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

    fs1 = FixScaled(a1.get_cell(), -1, mask=(True, False, False))
    fs2 = FixScaled(a1.get_cell(), 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)