• 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

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

4

5
from __future__ import annotations
1✔
6

7
import unittest
1✔
8

9
from pymatgen.analysis.interfaces.coherent_interfaces import (
1✔
10
    CoherentInterfaceBuilder,
11
    from_2d_to_3d,
12
    get_2d_transform,
13
    get_rot_3d_for_2d,
14
)
15
from pymatgen.symmetry.analyzer import SpacegroupAnalyzer
1✔
16
from pymatgen.util.testing import PymatgenTest
1✔
17

18

19
class InterfaceBuilderTest(PymatgenTest):
1✔
20
    @classmethod
1✔
21
    def setUpClass(cls):
1✔
22
        si_struct = cls.get_structure("Si")
1✔
23
        sio2_struct = cls.get_structure("SiO2")
1✔
24
        cls.si_conventional = SpacegroupAnalyzer(si_struct).get_conventional_standard_structure()
1✔
25
        cls.sio2_conventional = SpacegroupAnalyzer(sio2_struct).get_conventional_standard_structure()
1✔
26

27
    def test_utils(self):
1✔
28
        self.assertArrayAlmostEqual(from_2d_to_3d([[1, 2], [3, 4]]), [[1, 2, 0], [3, 4, 0], [0, 0, 1]])
1✔
29
        self.assertArrayAlmostEqual(get_2d_transform([[1, 0], [0, 1]], [[1, 2], [3, 4]]), [[1, 2], [3, 4]])
1✔
30
        self.assertArrayAlmostEqual(
1✔
31
            get_rot_3d_for_2d([[1, 0, 0], [0, 1, 0]], [[1, 1, 0], [0, 1, 1]]),
32
            [
33
                [0.78867513, -0.21132487, 0.57735027],
34
                [0.57735027, 0.57735027, -0.57735027],
35
                [-0.21132487, 0.78867513, 0.57735027],
36
            ],
37
        )
38

39
    def test_coherent_interface_builder(self):
1✔
40
        builder = CoherentInterfaceBuilder(
1✔
41
            film_structure=self.sio2_conventional,
42
            substrate_structure=self.si_conventional,
43
            film_miller=(1, 0, 0),
44
            substrate_miller=(1, 1, 1),
45
        )
46

47
        assert len(builder.terminations) == 2
1✔
48
        # SP: I am commenting out this test which is super fragile and the result fluctates between 6 and 30 for
49
        # no apparent reason. The author should fix this.
50
        # self.assertEqual(len(list(builder.get_interfaces(termination=("O2_Pmmm_1", "Si_R-3m_1")))), 30)
51

52

53
if __name__ == "__main__":
1✔
54
    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