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

pyiron / structuretoolkit / 5628806564

pending completion
5628806564

push

github-actions

web-flow
Merge pull request #24 from pyiron/pyxtal

Add pyxtal wrapper

70 of 70 new or added lines in 3 files covered. (100.0%)

2218 of 2549 relevant lines covered (87.01%)

0.87 hits per line

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

85.19
/tests/test_pyxtal.py
1
from unittest import TestCase, skipIf
1✔
2
from ase import Atoms
1✔
3
import structuretoolkit as stk
1✔
4

5

6
try:
1✔
7
    import pyxtal
1✔
8
    skip_pyxtal_test = False
1✔
9
except ImportError:
×
10
    skip_pyxtal_test = True
×
11

12

13
@skipIf(skip_pyxtal_test, "pyxtal is not installed, so the pyxtal tests are skipped.")
1✔
14
class TestPyxtal(TestCase):
1✔
15

16
    def test_args_raised(self):
1✔
17
        """pyxtal should raise appropriate errors when called with wrong arguments"""
18

19
        with self.assertRaises(ValueError, msg="No error raised when num_ions and species do not match!"):
1✔
20
            stk.build.pyxtal(1, species=['Fe'], num_ions=[1,2])
1✔
21

22
        with self.assertRaises(ValueError, msg="No error raised when num_ions and species do not match!"):
1✔
23
            stk.build.pyxtal(1, species=['Fe', 'Cr'], num_ions=[1])
1✔
24

25
        try:
1✔
26
            stk.build.pyxtal([193, 194], ['Mg'], num_ions=[1], allow_exceptions=True)
1✔
27
        except ValueError:
×
28
            self.fail("Error raised even though allow_exceptions=True was passed!")
×
29

30
        with self.assertRaises(ValueError, msg="No error raised even though allow_exceptions=False was passed!"):
1✔
31
            stk.build.pyxtal(194, ['Mg'], num_ions=[1], allow_exceptions=False)
1✔
32

33
    def test_return_value(self):
1✔
34
        """pyxtal should either return Atoms or list of dict, depending on arguments"""
35

36
        self.assertIsInstance(stk.build.pyxtal(1, species=['Fe'], num_ions=[1]), Atoms,
1✔
37
                              "returned not an Atoms with scalar arguments")
38
        self.assertIsInstance(stk.build.pyxtal([1, 2], species=['Fe'], num_ions=[1]), list,
1✔
39
                              "returned not a StructureStorage with multiple groups")
40
        self.assertIsInstance(stk.build.pyxtal(1, species=['Fe'], num_ions=[1], repeat=5), list,
1✔
41
                              "returned not a StructureStorage with repeat given")
42
        self.assertEqual(len(stk.build.pyxtal(1, species=['Fe'], num_ions=[1], repeat=5)), 5,
1✔
43
                         "returned number of structures did not match given repeat")
44
        self.assertTrue(all(isinstance(d, dict) for d in stk.build.pyxtal(1, species=['Fe'], num_ions=[1], repeat=5)),
1✔
45
                        "returned list should contain only dicts")
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