Skip to content

Commit 283d81d

Browse files
committed
TST: verify SG lookup by old alt_name values
Also cover the entire `GetSpaceGroup` code.
1 parent f65babd commit 283d81d

File tree

1 file changed

+33
-0
lines changed

1 file changed

+33
-0
lines changed

src/diffpy/structure/tests/testspacegroups.py

Lines changed: 33 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,39 @@ def setUp(self):
3030
return
3131

3232

33+
def test_old_alt_name(self):
34+
"check GetSpaceGroup lookup from deprecated alt_name values"
35+
# alt_name values which do not map to short_name or pdb_name
36+
altnames_sgnos = (
37+
("P M 3", 200), ("P N 3", 201), ("F M 3", 202),
38+
("F D 3", 203), ("I M 3", 204), ("P A 3", 205),
39+
("I A 3", 206), ("P M 3 M", 221), ("P N 3 N", 222),
40+
("P M 3 N", 223), ("P N 3 M", 224), ("F M 3 M", 225),
41+
("F M 3 C", 226), ("F D 3 M", 227), ("F D 3 C", 228),
42+
("I M 3 M", 229), ("I A 3 D", 230)
43+
)
44+
for name, sgno in altnames_sgnos:
45+
self.assertIs(GetSpaceGroup(sgno), GetSpaceGroup(name))
46+
return
47+
48+
49+
def test_GetSpaceGroup(self):
50+
"check GetSpaceGroup function"
51+
from diffpy.structure.spacegroups import sg125
52+
self.assertRaises(ValueError, GetSpaceGroup, 0)
53+
self.assertRaises(ValueError, GetSpaceGroup, 300)
54+
self.assertRaises(ValueError, GetSpaceGroup, "300")
55+
self.assertIs(sg125, GetSpaceGroup(125))
56+
self.assertIs(sg125, GetSpaceGroup("125"))
57+
self.assertIs(sg125, GetSpaceGroup("P4/nbm"))
58+
self.assertIs(sg125, GetSpaceGroup("P 4/n 2/b 2/m"))
59+
# old alt_name
60+
self.assertIs(sg125, GetSpaceGroup("P 4/N B M"))
61+
# upper case pdb_name
62+
self.assertIs(sg125, GetSpaceGroup("P 4/N 2/B 2/M"))
63+
return
64+
65+
3366
def test_FindSpaceGroup(self):
3467
"check FindSpaceGroup function"
3568
sg123 = GetSpaceGroup(123)

0 commit comments

Comments
 (0)