• 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

98.15
/pymatgen/analysis/tests/test_nmr.py
1
from __future__ import annotations
1✔
2

3
import unittest
1✔
4

5
import numpy as np
1✔
6
from pytest import approx
1✔
7

8
from pymatgen.analysis.nmr import ChemicalShielding, ElectricFieldGradient
1✔
9
from pymatgen.util.testing import PymatgenTest
1✔
10

11

12
class TestChemicalShieldingNotation(PymatgenTest):
1✔
13
    def test_construction(self):
1✔
14
        cs = ChemicalShielding(np.arange(9).reshape((3, 3)))
1✔
15
        assert cs.shape == (3, 3)
1✔
16

17
        cs = ChemicalShielding([1, 2, 3])
1✔
18
        assert cs.shape == (3, 3)
1✔
19
        self.assertArrayEqual(np.diag(cs), [1, 2, 3])
1✔
20

21
    def test_principal_axis_system(self):
1✔
22
        cs = ChemicalShielding([1, 2, 3])
1✔
23
        self.assertArrayEqual(cs.principal_axis_system, cs)
1✔
24

25
        cs = ChemicalShielding(np.arange(9).reshape((3, 3)))
1✔
26
        self.assertArrayAlmostEqual(
1✔
27
            np.diag(cs.principal_axis_system),
28
            [-1.74596669e00, -1.53807726e-15, 1.37459667e01],
29
            decimal=5,
30
        )
31

32
    def test_notations(self):
1✔
33
        cs = ChemicalShielding.from_maryland_notation(195.0788, 68.1733, 0.8337)
1✔
34
        hae1 = cs.haeberlen_values
1✔
35
        assert hae1.sigma_iso == approx(195.0788, abs=1e-5)
1✔
36
        assert hae1.delta_sigma_iso == approx(-65.33899505250002, abs=1e-5)
1✔
37
        assert hae1.zeta == approx(-43.559330035000016, abs=1e-5)
1✔
38
        assert hae1.eta == approx(0.13013537835511454, abs=1e-5)
1✔
39
        meh1 = cs.mehring_values
1✔
40
        assert meh1.sigma_iso == approx(195.0788, abs=1e-5)
1✔
41
        assert meh1.sigma_11 == approx(151.51946996499998, abs=1e-5)
1✔
42
        assert meh1.sigma_22 == approx(214.02416007, abs=1e-5)
1✔
43
        assert meh1.sigma_33 == approx(219.69276996500002, abs=1e-5)
1✔
44
        mary1 = cs.maryland_values
1✔
45
        assert mary1.sigma_iso == approx(195.0788, abs=1e-5)
1✔
46
        assert mary1.omega == approx(68.1733, abs=1e-5)
1✔
47
        assert mary1.kappa == approx(0.8337, abs=1e-5)
1✔
48

49

50
class TestElectricFieldGradient(PymatgenTest):
1✔
51
    def test_construction(self):
1✔
52
        efg = ElectricFieldGradient(np.arange(9).reshape((3, 3)))
1✔
53
        assert efg.shape == (3, 3)
1✔
54

55
        efg = ElectricFieldGradient([1, 2, 3])
1✔
56
        assert efg.shape == (3, 3)
1✔
57

58
    def test_principal_axis_system(self):
1✔
59
        efg = ElectricFieldGradient([1, 2, 3])
1✔
60
        self.assertArrayEqual(efg.principal_axis_system, efg)
1✔
61

62
        efg = ElectricFieldGradient(np.arange(9).reshape((3, 3)))
1✔
63
        self.assertArrayAlmostEqual(
1✔
64
            np.diag(efg.principal_axis_system),
65
            [-1.3484692e00, -1.1543332e-15, 1.3348469e01],
66
            decimal=5,
67
        )
68

69
    def test_Attributes(self):
1✔
70
        efg = ElectricFieldGradient([[11.11, 1.371, 2.652], [1.371, 3.635, -3.572], [2.652, -3.572, -14.746]])
1✔
71
        assert efg.V_yy == approx(11.516, abs=1e-3)
1✔
72
        assert efg.V_xx == approx(4.204, abs=1e-3)
1✔
73
        assert efg.V_zz == approx(-15.721, abs=1e-3)
1✔
74
        assert efg.asymmetry == approx(0.465, abs=1e-3)
1✔
75
        assert efg.coupling_constant("Al") == approx(5.573, abs=1e-3)
1✔
76

77

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