diff --git a/devutils/sgtbx_extra_groups.py b/devutils/sgtbx_extra_groups.py index 1c718fa8..e5a96189 100644 --- a/devutils/sgtbx_extra_groups.py +++ b/devutils/sgtbx_extra_groups.py @@ -17,7 +17,7 @@ import numpy from cctbx import sgtbx -from diffpy.structure.spacegroups import IsSpaceGroupIdentifier, SpaceGroup, SymOp, mmLibSpaceGroupList +from diffpy.structure.spacegroups import SpaceGroup, SymOp, is_space_group_identifier, mmLibSpaceGroupList def tupleToSGArray(tpl): @@ -196,7 +196,7 @@ def main(): if findEquivalentMMSpaceGroup(grp): continue shn = smbls.hermann_mauguin().replace(" ", "") - if IsSpaceGroupIdentifier(shn): + if is_space_group_identifier(shn): continue sg = mmSpaceGroupFromSymbol(uhm) hsg = hashMMSpaceGroup(sg) diff --git a/news/deprecate-spacegroup.rst b/news/deprecate-spacegroup.rst new file mode 100644 index 00000000..902e4fdb --- /dev/null +++ b/news/deprecate-spacegroup.rst @@ -0,0 +1,33 @@ +**Added:** + +* Added ``get_symop`` method in ``parsers/p_cif.py`` +* Added ``get_space_group`` method in ``spacegroups.py`` +* Added ``find_space_group`` method in ``spacegroups.py`` +* Added ``is_space_group_identifier`` method in ``spacegroups.py`` +* Added ``_hash_symop_list`` method in ``spacegroups.py`` +* Added ``_build_sg_lookup_table`` method in ``spacegroups.py`` +* Added ``_get_sg_hash_lookup_table`` method in ``spacegroups.py`` + +**Changed:** + +* + +**Deprecated:** + +* Deprecated ``getSymOp`` method in ``parsers/p_cif.py`` for removal in version 4.0.0 +* Deprecated ``GetSpaceGroup`` method in ``spacegroups.py`` for removal in version 4.0.0 +* Deprecated ``IsSpaceGroupIdentifier`` method in ``spacegroups.py`` for removal in version 4.0.0 +* Deprecated ``FindSpaceGroup`` method in ``spacegroups.py`` for removal in version 4.0.0 +* Deprecated ``_hashSymOpList`` method in ``spacegroups.py`` for removal in version 4.0.0 + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/structure/parsers/p_cif.py b/src/diffpy/structure/parsers/p_cif.py index 679c4ccf..1dc39d7c 100644 --- a/src/diffpy/structure/parsers/p_cif.py +++ b/src/diffpy/structure/parsers/p_cif.py @@ -593,7 +593,12 @@ def _parse_space_group_symop_operation_xyz(self, block): block : CifBlock Instance of `CifBlock`. """ - from diffpy.structure.spacegroups import FindSpaceGroup, GetSpaceGroup, IsSpaceGroupIdentifier, SpaceGroup + from diffpy.structure.spacegroups import ( + SpaceGroup, + find_space_group, + get_space_group, + is_space_group_identifier, + ) self.asymmetric_unit = list(self.stru) sym_synonyms = ( @@ -608,7 +613,7 @@ def _parse_space_group_symop_operation_xyz(self, block): sym_loop_name = sym_loop_name[0] sym_loop = block.GetLoop(sym_loop_name) for eqxyz in sym_loop[sym_loop_name]: - opcif = getSymOp(eqxyz) + opcif = get_symop(eqxyz) symop_list.append(opcif) # determine space group number sg_nameHall = block.get("_space_group_name_Hall", "") or block.get("_symmetry_space_group_name_Hall", "") @@ -623,12 +628,12 @@ def _parse_space_group_symop_operation_xyz(self, block): # try to reuse existing space group from symmetry operations if symop_list: try: - self.spacegroup = FindSpaceGroup(symop_list) + self.spacegroup = find_space_group(symop_list) except ValueError: pass # otherwise lookup the space group from its identifier - if self.spacegroup is None and sgid and IsSpaceGroupIdentifier(sgid): - self.spacegroup = GetSpaceGroup(sgid) + if self.spacegroup is None and sgid and is_space_group_identifier(sgid): + self.spacegroup = get_space_group(sgid) # define new spacegroup when symmetry operations were listed, but # there is no match to an existing definition if symop_list and self.spacegroup is None: @@ -824,6 +829,12 @@ def to_lines(self, stru): "get_parser", removal_version, ) +getSymOp_deprecation_msg = build_deprecation_message( + parsers_base, + "getSymOp", + "get_symop", + removal_version, +) # constant regular expression for leading_float() rx_float = re.compile(r"[-+]?(\d+(\.\d*)?|\.\d+)([eE][-+]?\d+)?") @@ -878,7 +889,17 @@ def leading_float(s, d=0.0): symvec["+z"] = symvec["z"] +@deprecated(getSymOp_deprecation_msg) def getSymOp(s): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.structure.get_symop instead. + """ + return get_symop(s) + + +def get_symop(s): """Create `SpaceGroups.SymOp` instance from a string. Parameters @@ -913,7 +934,7 @@ def getParser(eps=None): """This function has been deprecated and will be removed in version 4.0.0. - Please use diffpy.structure.P_cif.get_parser instead. + Please use diffpy.structure.get_parser instead. """ return get_parser(eps) diff --git a/src/diffpy/structure/spacegroups.py b/src/diffpy/structure/spacegroups.py index a5d33372..8b6fb8c5 100644 --- a/src/diffpy/structure/spacegroups.py +++ b/src/diffpy/structure/spacegroups.py @@ -643,14 +643,50 @@ Tr_34_34_14, Tr_34_34_34, ) +from diffpy.utils._deprecator import build_deprecation_message, deprecated # Import SpaceGroup objects -------------------------------------------------- - +base = "diffpy.structure" +removal_version = "4.0.0" +GetSpaceGroup_deprecation_msg = build_deprecation_message( + base, + "GetSpaceGroup", + "get_space_group", + removal_version, +) +FindSpaceGroup_deprecation_msg = build_deprecation_message( + base, + "FindSpaceGroup", + "find_space_group", + removal_version, +) +IsSpaceGroupIdentifier_deprecation_msg = build_deprecation_message( + base, + "IsSpaceGroupIdentifier", + "is_space_group_identifier", + removal_version, +) +_hashSymOpList_deprecation_msg = build_deprecation_message( + base, + "_hashSymOpList", + "_hash_symop_list", + removal_version, +) SpaceGroupList = mmLibSpaceGroupList + sgtbxSpaceGroupList +@deprecated(GetSpaceGroup_deprecation_msg) def GetSpaceGroup(sgid): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.structure.get_space_group instead. + """ + return get_space_group(sgid) + + +def get_space_group(sgid): """Returns the SpaceGroup instance for the given identifier. Parameters @@ -670,7 +706,7 @@ def GetSpaceGroup(sgid): When the identifier is not found. """ if not _sg_lookup_table: - _buildSGLookupTable() + _build_sg_lookup_table() if sgid in _sg_lookup_table: return _sg_lookup_table[sgid] # Try different versions of sgid, first make sure it is a string @@ -691,10 +727,22 @@ def GetSpaceGroup(sgid): raise ValueError(emsg) +@deprecated(IsSpaceGroupIdentifier_deprecation_msg) def IsSpaceGroupIdentifier(sgid): """Check if identifier can be used as an argument to `GetSpaceGroup`. + Returns + ------- + bool + """ + return is_space_group_identifier(sgid) + + +def is_space_group_identifier(sgid): + """Check if identifier can be used as an argument to + `GetSpaceGroup`. + Returns ------- bool @@ -707,7 +755,17 @@ def IsSpaceGroupIdentifier(sgid): return rv +@deprecated(FindSpaceGroup_deprecation_msg) def FindSpaceGroup(symops, shuffle=False): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.structure.find_space_group instead. + """ + return find_space_group(symops, shuffle=shuffle) + + +def find_space_group(symops, shuffle=False): """Lookup SpaceGroup from a given list of symmetry operations. Parameters @@ -732,8 +790,8 @@ def FindSpaceGroup(symops, shuffle=False): When `symops` do not match any known SpaceGroup. """ - tb = _getSGHashLookupTable() - hh = _hashSymOpList(symops) + tb = _get_sg_hash_lookup_table() + hh = _hash_symop_list(symops) if hh not in tb: raise ValueError("Cannot find SpaceGroup for the specified symops.") rv = tb[hh] @@ -746,7 +804,17 @@ def FindSpaceGroup(symops, shuffle=False): return rv +@deprecated(_hashSymOpList_deprecation_msg) def _hashSymOpList(symops): + """This function has been deprecated and will be removed in version + 4.0.0. + + Please use diffpy.structure._hash_symop_list instead. + """ + return _hash_symop_list(symops) + + +def _hash_symop_list(symops): """Return hash value for a sequence of `SymOp` objects. The symops are sorted so the results is independent of symops order. @@ -766,7 +834,7 @@ def _hashSymOpList(symops): return rv -def _buildSGLookupTable(): +def _build_sg_lookup_table(): """Rebuild space group lookup table from the `SpaceGroupList` data. This routine updates the global `_sg_lookup_table` dictionary. @@ -809,16 +877,16 @@ def _buildSGLookupTable(): _sg_lookup_table = {} -def _getSGHashLookupTable(): +def _get_sg_hash_lookup_table(): """Return lookup table of symop hashes to standard `SpaceGroup` objects.""" if _sg_hash_lookup_table: return _sg_hash_lookup_table for sg in SpaceGroupList: - h = _hashSymOpList(sg.symop_list) + h = _hash_symop_list(sg.symop_list) _sg_hash_lookup_table[h] = sg assert len(_sg_hash_lookup_table) == len(SpaceGroupList) - return _getSGHashLookupTable() + return _get_sg_hash_lookup_table() _sg_hash_lookup_table = {} diff --git a/tests/test_p_cif.py b/tests/test_p_cif.py index fd63f03b..5784ecfd 100644 --- a/tests/test_p_cif.py +++ b/tests/test_p_cif.py @@ -21,7 +21,7 @@ from diffpy.structure import Structure from diffpy.structure.parsers import get_parser, getParser -from diffpy.structure.parsers.p_cif import P_cif, getSymOp, leading_float +from diffpy.structure.parsers.p_cif import P_cif, get_symop, getSymOp, leading_float from diffpy.structure.structureerrors import StructureFormatError # ---------------------------------------------------------------------------- @@ -56,6 +56,20 @@ def test_getSymOp(self): self.assertEqual(str(op1_std), str(op1)) return + def test_get_symop(self): + """Check get_symop()""" + from diffpy.structure.spacegroups import Rot_X_mY_Z, SymOp, Tr_0_12_12 + + op = get_symop("x,1/2-y,1/2+z") + op_std = SymOp(Rot_X_mY_Z, Tr_0_12_12) + self.assertEqual(str(op_std), str(op)) + from diffpy.structure.spacegroups import Rot_mX_mXY_Z, Tr_0_0_12 + + op1 = get_symop("-x,-x+y,1/2+z") + op1_std = SymOp(Rot_mX_mXY_Z, Tr_0_0_12) + self.assertEqual(str(op1_std), str(op1)) + return + # End of class TestRoutines @@ -332,7 +346,7 @@ def test_unknown_occupancy(self): def test_unknown_spacegroup_number(self): "test CIF file with unknown space group symbol" - from diffpy.structure.spacegroups import GetSpaceGroup, _hashSymOpList + from diffpy.structure.spacegroups import _hash_symop_list, get_space_group with open(self.pbteciffile) as fp: lines = fp.readlines() @@ -346,9 +360,9 @@ def test_unknown_spacegroup_number(self): ciftxt = "".join(lines) stru = self.ptest.parse(ciftxt) self.assertEqual(8, len(stru)) - h225 = _hashSymOpList(GetSpaceGroup(225).iter_symops()) + h225 = _hash_symop_list(get_space_group(225).iter_symops()) sgcif = self.ptest.spacegroup - self.assertEqual(h225, _hashSymOpList(sgcif.iter_symops())) + self.assertEqual(h225, _hash_symop_list(sgcif.iter_symops())) return def test_nosites_cif(self): diff --git a/tests/test_spacegroups.py b/tests/test_spacegroups.py index 7eb3f97d..de5fd69d 100644 --- a/tests/test_spacegroups.py +++ b/tests/test_spacegroups.py @@ -17,7 +17,15 @@ import unittest -from diffpy.structure.spacegroups import FindSpaceGroup, GetSpaceGroup, SpaceGroupList, _hashSymOpList +from diffpy.structure.spacegroups import ( + FindSpaceGroup, + GetSpaceGroup, + SpaceGroupList, + _hash_symop_list, + _hashSymOpList, + find_space_group, + get_space_group, +) # ---------------------------------------------------------------------------- @@ -50,7 +58,7 @@ def test_old_alt_name(self): ("I A 3 D", 230), ) for name, sgno in altnames_sgnos: - self.assertIs(GetSpaceGroup(sgno), GetSpaceGroup(name)) + self.assertIs(get_space_group(sgno), get_space_group(name)) return def test_GetSpaceGroup(self): @@ -70,9 +78,26 @@ def test_GetSpaceGroup(self): self.assertIs(sg125, GetSpaceGroup("P 4/N 2/B 2/M")) return + def test_get_space_group(self): + "check get_space_group function" + from diffpy.structure.spacegroups import sg125 + + self.assertRaises(ValueError, get_space_group, 0) + self.assertRaises(ValueError, get_space_group, 300) + self.assertRaises(ValueError, get_space_group, "300") + self.assertIs(sg125, get_space_group(125)) + self.assertIs(sg125, get_space_group("125")) + self.assertIs(sg125, get_space_group("P4/nbm")) + self.assertIs(sg125, get_space_group("P 4/n 2/b 2/m")) + # old alt_name + self.assertIs(sg125, get_space_group("P 4/N B M")) + # upper case pdb_name + self.assertIs(sg125, get_space_group("P 4/N 2/B 2/M")) + return + def test_FindSpaceGroup(self): "check FindSpaceGroup function" - sg123 = GetSpaceGroup(123) + sg123 = get_space_group(123) ops123 = list(sg123.iter_symops()) self.assertRaises(ValueError, FindSpaceGroup, []) self.assertRaises(ValueError, FindSpaceGroup, 2 * ops123) @@ -81,44 +106,65 @@ def test_FindSpaceGroup(self): 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.assertEqual(_hash_symop_list(sg123.symop_list), _hash_symop_list(sg123r.symop_list)) self.assertIs(sg123, FindSpaceGroup(ops123[::-1], shuffle=True)) return + def test_find_space_group(self): + "check find_space_group function" + sg123 = get_space_group(123) + ops123 = list(sg123.iter_symops()) + self.assertRaises(ValueError, find_space_group, []) + self.assertRaises(ValueError, find_space_group, 2 * ops123) + self.assertIs(sg123, find_space_group(ops123)) + sg123r = find_space_group(ops123[::-1]) + self.assertIsNot(sg123, sg123r) + self.assertIsNot(sg123.symop_list, sg123r.symop_list) + self.assertEqual(ops123[::-1], sg123r.symop_list) + self.assertEqual(_hash_symop_list(sg123.symop_list), _hash_symop_list(sg123r.symop_list)) + self.assertIs(sg123, find_space_group(ops123[::-1], shuffle=True)) + 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 + def test__hash_symop_list(self): + "verify _hash_symop_list is unique for each spacegroup" + hset = set(_hash_symop_list(sg.symop_list) for sg in SpaceGroupList) + self.assertEqual(len(SpaceGroupList), len(hset)) + return + def test_spacegroup_representation(self): """Verify SpaceGroup.__repr__().""" self.assertEqual( - repr(GetSpaceGroup(1)), + repr(get_space_group(1)), "SpaceGroup #1 (P1, Triclinic). Symmetry matrices: 1, point sym. matr.: 1", ) self.assertEqual( - repr(GetSpaceGroup(3)), + repr(get_space_group(3)), "SpaceGroup #3 (P2, Monoclinic). Symmetry matrices: 2, point sym. matr.: 2", ) self.assertEqual( - repr(GetSpaceGroup(16)), + repr(get_space_group(16)), ("SpaceGroup #16 (P222, Orthorhombic). Symmetry matrices: 4, point sym. " "matr.: 4"), ) self.assertEqual( - repr(GetSpaceGroup(75)), + repr(get_space_group(75)), "SpaceGroup #75 (P4, Tetragonal). Symmetry matrices: 4, point sym. matr.: 4", ) self.assertEqual( - repr(GetSpaceGroup(143)), + repr(get_space_group(143)), "SpaceGroup #143 (P3, Trigonal). Symmetry matrices: 3, point sym. matr.: 3", ) self.assertEqual( - repr(GetSpaceGroup(168)), + repr(get_space_group(168)), "SpaceGroup #168 (P6, Hexagonal). Symmetry matrices: 6, point sym. matr.: 6", ) self.assertEqual( - repr(GetSpaceGroup(229)), + repr(get_space_group(229)), ("SpaceGroup #229 (Im-3m, Cubic). Symmetry matrices: 96, point sym. " "matr.: 48"), ) return diff --git a/tests/test_symmetryutilities.py b/tests/test_symmetryutilities.py index b767190f..c5b37fc8 100644 --- a/tests/test_symmetryutilities.py +++ b/tests/test_symmetryutilities.py @@ -21,7 +21,7 @@ import numpy import pytest -from diffpy.structure.spacegroups import GetSpaceGroup +from diffpy.structure.spacegroups import get_space_group from diffpy.structure.structureerrors import SymmetryError from diffpy.structure.symmetryutilities import ( ExpandAsymmetricUnit, @@ -59,13 +59,13 @@ def tearDown(self): def test_isSpaceGroupLatPar(self): """Check isSpaceGroupLatPar()""" - triclinic = GetSpaceGroup("P1") - monoclinic = GetSpaceGroup("P2") - orthorhombic = GetSpaceGroup("P222") - tetragonal = GetSpaceGroup("P4") - trigonal = GetSpaceGroup("P3") - hexagonal = GetSpaceGroup("P6") - cubic = GetSpaceGroup("P23") + triclinic = get_space_group("P1") + monoclinic = get_space_group("P2") + orthorhombic = get_space_group("P222") + tetragonal = get_space_group("P4") + trigonal = get_space_group("P3") + hexagonal = get_space_group("P6") + cubic = get_space_group("P23") self.assertTrue(isSpaceGroupLatPar(triclinic, 1, 2, 3, 40, 50, 60)) self.assertFalse(isSpaceGroupLatPar(monoclinic, 1, 2, 3, 40, 50, 60)) self.assertTrue(isSpaceGroupLatPar(monoclinic, 1, 2, 3, 90, 50, 90)) @@ -83,13 +83,13 @@ def test_isSpaceGroupLatPar(self): def test_is_space_group_lat_par(self): """Check isSpaceGroupLatPar()""" - triclinic = GetSpaceGroup("P1") - monoclinic = GetSpaceGroup("P2") - orthorhombic = GetSpaceGroup("P222") - tetragonal = GetSpaceGroup("P4") - trigonal = GetSpaceGroup("P3") - hexagonal = GetSpaceGroup("P6") - cubic = GetSpaceGroup("P23") + triclinic = get_space_group("P1") + monoclinic = get_space_group("P2") + orthorhombic = get_space_group("P222") + tetragonal = get_space_group("P4") + trigonal = get_space_group("P3") + hexagonal = get_space_group("P6") + cubic = get_space_group("P23") self.assertTrue(is_space_group_latt_parms(triclinic, 1, 2, 3, 40, 50, 60)) self.assertFalse(is_space_group_latt_parms(monoclinic, 1, 2, 3, 40, 50, 60)) self.assertTrue(is_space_group_latt_parms(monoclinic, 1, 2, 3, 90, 50, 90)) @@ -106,9 +106,9 @@ def test_is_space_group_lat_par(self): return def test_sgtbx_spacegroup_aliases(self): - """Check GetSpaceGroup for non-standard aliases from sgtbx.""" - self.assertIs(GetSpaceGroup("Fm3m"), GetSpaceGroup(225)) - self.assertIs(GetSpaceGroup("Ia3d"), GetSpaceGroup("I a -3 d")) + """Check get_space_group for non-standard aliases from sgtbx.""" + self.assertIs(get_space_group("Fm3m"), get_space_group(225)) + self.assertIs(get_space_group("Ia3d"), get_space_group("I a -3 d")) return def test_positionDifference(self): @@ -126,7 +126,7 @@ def test_nearestSiteIndex(self): def test_expandPosition(self): """Check expandPosition()""" # ok again Ni example - fcc = GetSpaceGroup(225) + fcc = get_space_group(225) pos, pops, pmult = expandPosition(fcc, [0, 0, 0]) self.assertTrue(numpy.all(pos[0] == 0.0)) self.assertEqual(4, len(pos)) @@ -137,7 +137,7 @@ def test_expandPosition(self): def test_expand_position(self): """Check expand_position()""" # ok again Ni example - fcc = GetSpaceGroup(225) + fcc = get_space_group(225) pos, pops, pmult = expand_position(fcc, [0, 0, 0]) self.assertTrue(numpy.all(pos[0] == 0.0)) self.assertEqual(4, len(pos)) @@ -234,13 +234,13 @@ def setUp(self): if TestGeneratorSite.generators: self.__dict__.update(TestGeneratorSite.generators) return - sg117 = GetSpaceGroup(117) - sg143 = GetSpaceGroup(143) - sg164 = GetSpaceGroup(164) - sg167h = GetSpaceGroup("H-3c") - sg167r = GetSpaceGroup("R-3c") - sg186 = GetSpaceGroup(186) - sg227 = GetSpaceGroup(227) + sg117 = get_space_group(117) + sg143 = get_space_group(143) + sg164 = get_space_group(164) + sg167h = get_space_group("H-3c") + sg167r = get_space_group("R-3c") + sg186 = get_space_group(186) + sg227 = get_space_group(227) g117c = GeneratorSite(sg117, [0, 0.5, 0]) g117h = GeneratorSite(sg117, [x, x + 0.5, 0.5]) g143a = GeneratorSite(sg143, [0, 0, z]) @@ -368,7 +368,7 @@ def test_position_formula(self): def test_positionFormula_sg209(self): "check positionFormula at [x, 1-x, -x] site of the F432 space group." - sg209 = GetSpaceGroup("F 4 3 2") + sg209 = get_space_group("F 4 3 2") xyz = [0.05198, 0.94802, -0.05198] g209e = GeneratorSite(sg209, xyz) pfm = g209e.positionFormula(xyz) @@ -379,7 +379,7 @@ def test_positionFormula_sg209(self): def test_position_formula_sg209(self): "check positionFormula at [x, 1-x, -x] site of the F432 space group." - sg209 = GetSpaceGroup("F 4 3 2") + sg209 = get_space_group("F 4 3 2") xyz = [0.05198, 0.94802, -0.05198] g209e = GeneratorSite(sg209, xyz) pfm = g209e.position_formula(xyz) @@ -603,7 +603,7 @@ def test_u_formula(self): def test_UFormula_g186c_eqxyz(self): """Check rotated U formulas at the symmetry positions of c-site in 186.""" - sg186 = GetSpaceGroup(186) + sg186 = get_space_group(186) crules = [ { "U11": "A", @@ -685,7 +685,7 @@ def test_UFormula_g186c_eqxyz(self): def test_u_formula_g186c_eqxyz(self): """Check rotated U formulas at the symmetry positions of c-site in 186.""" - sg186 = GetSpaceGroup(186) + sg186 = get_space_group(186) crules = [ { "U11": "A", @@ -786,7 +786,7 @@ def test__findUParameters(self): self.assertEqual(0.0, uval) # special test for g117h Uij = numpy.array([[1, 3, 4], [3, 1, -4], [4, -4, 2]]) - sg117 = GetSpaceGroup(117) + sg117 = get_space_group(117) g117h = GeneratorSite(sg117, self.g117h.xyz, Uij) upd = dict(g117h.Uparameters) self.assertEqual(1, upd["U11"]) @@ -821,7 +821,7 @@ def tearDown(self): def test___init__(self): """Check SymmetryConstraints.__init__()""" - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) # initialize from nested lists and arrays from ExpandAsymmetricUnit eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc0 = SymmetryConstraints(sg225, eau.expandedpos) @@ -845,7 +845,7 @@ def test___init__(self): def test_corepos(self): """test_corepos - find positions in the asymmetric unit.""" - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) corepos = [[0, 0, 0], [0.1, 0.13, 0.17]] eau = ExpandAsymmetricUnit(sg225, corepos) sc = SymmetryConstraints(sg225, eau.expandedpos) @@ -861,7 +861,7 @@ def test_corepos(self): def test_Uisotropy(self): """Check isotropy value for ADP-s at specified sites.""" - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) corepos = [[0, 0, 0], [0.1, 0.13, 0.17]] eau = ExpandAsymmetricUnit(sg225, corepos) self.assertEqual([True, False], eau.Uisotropy) @@ -896,8 +896,8 @@ def test_Uisotropy(self): # def test_UparSymbols(self): """Check SymmetryConstraints.UparSymbols()""" - sg1 = GetSpaceGroup(1) - sg225 = GetSpaceGroup(225) + sg1 = get_space_group(1) + sg225 = get_space_group(225) pos = [[0, 0, 0]] Uijs = numpy.zeros((1, 3, 3)) sc1 = SymmetryConstraints(sg1, pos, Uijs) @@ -908,8 +908,8 @@ def test_UparSymbols(self): def test_upar_symbols(self): """Check SymmetryConstraints.UparSymbols()""" - sg1 = GetSpaceGroup(1) - sg225 = GetSpaceGroup(225) + sg1 = get_space_group(1) + sg225 = get_space_group(225) pos = [[0, 0, 0]] Uijs = numpy.zeros((1, 3, 3)) sc1 = SymmetryConstraints(sg1, pos, Uijs) @@ -921,8 +921,8 @@ def test_upar_symbols(self): def test_UparValues(self): """Check SymmetryConstraints.UparValues()""" places = 12 - sg1 = GetSpaceGroup(1) - sg225 = GetSpaceGroup(225) + sg1 = get_space_group(1) + sg225 = get_space_group(225) pos = [[0, 0, 0]] Uijs = [[[0.1, 0.4, 0.5], [0.4, 0.2, 0.6], [0.5, 0.6, 0.3]]] sc1 = SymmetryConstraints(sg1, pos, Uijs) @@ -936,8 +936,8 @@ def test_UparValues(self): def test_upar_values(self): """Check SymmetryConstraints.UparValues()""" places = 12 - sg1 = GetSpaceGroup(1) - sg225 = GetSpaceGroup(225) + sg1 = get_space_group(1) + sg225 = get_space_group(225) pos = [[0, 0, 0]] Uijs = [[[0.1, 0.4, 0.5], [0.4, 0.2, 0.6], [0.5, 0.6, 0.3]]] sc1 = SymmetryConstraints(sg1, pos, Uijs) @@ -950,7 +950,7 @@ def test_upar_values(self): def test_posparSymbols_and_posparValues(self): """Check SymmetryConstraints.posparSymbols and_posparValues()""" - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.pospars = [("x", 0.12), ("y", 0.34), ("z", 0.56)] @@ -962,7 +962,7 @@ def test_posparSymbols_and_posparValues(self): assert expected_values == actual_values def test_positionFormulas(self): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) # C1: Simulate the "not enough symbols" branch @@ -983,7 +983,7 @@ def test_positionFormulas(self): assert actual == expected def test_positionFormulasPruned(self): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) # C1: Remove any key-value pairs with constant values @@ -1017,7 +1017,7 @@ def test_UFormulasPruned(self): "U12": "0.5*A", } ] - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.Ueqns = [u_formulas] @@ -1168,7 +1168,7 @@ def test_null_space(A, expected_dim): ) def test_pospar_symbols_and_pospar_values(params, expected_symbols, expected_values): """Check SymmetryConstraints.pospar_symbols and_pospar_values()""" - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.pospars = params @@ -1184,7 +1184,7 @@ def test_pospar_symbols_and_pospar_values(params, expected_symbols, expected_val ], ) def test_position_formulas_raises_SymmetryError(params): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.pospars = [("x1", 0.12), ("y1", 0.34), ("z1", 0.56)] @@ -1211,7 +1211,7 @@ def test_position_formulas_raises_SymmetryError(params): ], ) def test_position_formulas(params, expected): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.pospars = [("x1", 0.12), ("y1", 0.34), ("z1", 0.56)] @@ -1239,7 +1239,7 @@ def test_position_formulas(params, expected): ], ) def test_position_formulas_pruned(poseqns, expected): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) @@ -1276,7 +1276,7 @@ def test_position_formulas_pruned(poseqns, expected): ], ) def test_u_formula_pruned(u_formulas, expected): - sg225 = GetSpaceGroup(225) + sg225 = get_space_group(225) eau = ExpandAsymmetricUnit(sg225, [[0, 0, 0]]) sc = SymmetryConstraints(sg225, eau.expandedpos) sc.Ueqns = u_formulas