def test_FindSpaceGroup(self): "check FindSpaceGroup function" sg123 = GetSpaceGroup(123) ops123 = list(sg123.iter_symops()) self.assertRaises(ValueError, FindSpaceGroup, []) self.assertRaises(ValueError, FindSpaceGroup, 2 * ops123) self.assertIs(sg123, FindSpaceGroup(ops123)) sg123r = FindSpaceGroup(ops123[::-1]) self.assertIsNot(sg123, sg123r) self.assertIsNot(sg123.symop_list, sg123r.symop_list) self.assertEqual(ops123[::-1], sg123r.symop_list) self.assertEqual(_hashSymOpList(sg123.symop_list), _hashSymOpList(sg123r.symop_list)) self.assertIs(sg123, FindSpaceGroup(ops123[::-1], shuffle=True)) return
def test_unknown_spacegroup_number(self): "test CIF file with unknown space group symbol" from diffpy.structure.spacegroups import GetSpaceGroup, _hashSymOpList with open(self.pbteciffile) as fp: lines = fp.readlines() self.assertTrue(lines[16].startswith('_symmetry_space_group')) self.assertTrue(lines[17].startswith('_symmetry_space_group')) lines[16:18] = [ '_space_group_IT_number ?\n', '_symmetry_space_group_name_H-M ?\n', '_symmetry_space_group_name_Hall ?\n', ] ciftxt = ''.join(lines) stru = self.ptest.parse(ciftxt) self.assertEqual(8, len(stru)) h225 = _hashSymOpList(GetSpaceGroup(225).iter_symops()) sgcif = self.ptest.spacegroup self.assertEqual(h225, _hashSymOpList(sgcif.iter_symops())) return
def test__hashSymOpList(self): "verify _hashSymOpList is unique for each spacegroup" hset = set(_hashSymOpList(sg.symop_list) for sg in SpaceGroupList) self.assertEqual(len(SpaceGroupList), len(hset)) return