• Home
  • Features
  • Pricing
  • Docs
  • Announcements
  • Sign In

materialsproject / pymatgen / 4075885785

pending completion
4075885785

push

github

Shyue Ping Ong
Merge branch 'master' of github.com:materialsproject/pymatgen

96 of 96 new or added lines in 27 files covered. (100.0%)

81013 of 102710 relevant lines covered (78.88%)

0.79 hits per line

Source File
Press 'n' to go to next uncovered line, 'b' for previous

97.5
/pymatgen/analysis/interfaces/tests/test_zsl.py
1
# Copyright (c) Pymatgen Development Team.
2
# Distributed under the terms of the MIT License.
3

4
from __future__ import annotations
1✔
5

6
import unittest
1✔
7

8
import pytest
1✔
9

10
from pymatgen.analysis.interfaces.zsl import (
1✔
11
    ZSLGenerator,
12
    fast_norm,
13
    get_factors,
14
    reduce_vectors,
15
    vec_area,
16
)
17
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
1✔
18
from pymatgen.util.testing import PymatgenTest
1✔
19

20
__author__ = "Shyam Dwaraknath"
1✔
21
__copyright__ = "Copyright 2016, The Materials Project"
1✔
22
__version__ = "0.1"
1✔
23
__maintainer__ = "Shyam Dwaraknath"
1✔
24
__email__ = "shyamd@lbl.gov"
1✔
25
__date__ = "2/5/16"
1✔
26

27

28
class ZSLGenTest(PymatgenTest):
1✔
29
    def setUp(self):
1✔
30
        # Film VO2
31
        self.film = SpacegroupAnalyzer(self.get_structure("VO2"), symprec=0.1).get_conventional_standard_structure()
1✔
32

33
        # Substrate TiO2
34
        self.substrate = SpacegroupAnalyzer(
1✔
35
            self.get_structure("TiO2"), symprec=0.1
36
        ).get_conventional_standard_structure()
37

38
    def test_zsl(self):
1✔
39
        z = ZSLGenerator()
1✔
40

41
        assert fast_norm([3, 2, 1]) == pytest.approx(3.74165738)
1✔
42
        self.assertArrayEqual(reduce_vectors([1, 0, 0], [2, 2, 0]), [[1, 0, 0], [0, 2, 0]])
1✔
43
        assert vec_area([1, 0, 0], [0, 2, 0]) == 2
1✔
44
        self.assertArrayEqual(list(get_factors(18)), [1, 2, 3, 6, 9, 18])
1✔
45
        assert z.is_same_vectors([[1.01, 0, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])
1✔
46
        assert not z.is_same_vectors([[1.01, 2, 0], [0, 2, 0]], [[1, 0, 0], [0, 2.01, 0]])
1✔
47

48
        matches = list(z(self.film.lattice.matrix[:2], self.substrate.lattice.matrix[:2]))
1✔
49
        assert len(matches) == 8
1✔
50

51
    def test_bidirectional(self):
1✔
52
        z = ZSLGenerator(max_area_ratio_tol=0.05, max_angle_tol=0.05, max_length_tol=0.05)
1✔
53

54
        matches = list(z(self.film.lattice.matrix[:2], self.substrate.lattice.matrix[:2]))
1✔
55
        assert len(matches) == 48
1✔
56

57
        matches = list(z(self.substrate.lattice.matrix[:2], self.film.lattice.matrix[:2]))
1✔
58
        assert len(matches) == 40
1✔
59

60
        z.bidirectional = True
1✔
61
        matches = list(z(self.substrate.lattice.matrix[:2], self.film.lattice.matrix[:2]))
1✔
62
        assert len(matches) == 48
1✔
63

64
        for match in matches:
1✔
65
            assert match is not None
1✔
66
            assert isinstance(match.match_area, float)
1✔
67

68

69
if __name__ == "__main__":
1✔
70
    unittest.main()
×
STATUS · Troubleshooting · Open an Issue · Sales · Support · CAREERS · ENTERPRISE · START FREE · SCHEDULE DEMO
ANNOUNCEMENTS · TWITTER · TOS & SLA · Supported CI Services · What's a CI service? · Automated Testing

© 2025 Coveralls, Inc