diffpy.structure 3.5.0rc0__py3-none-any.whl → 3.5.1__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -888,6 +888,35 @@ symvec["+y"] = symvec["y"]
888
888
  symvec["+z"] = symvec["z"]
889
889
 
890
890
 
891
+ _symop_number = r"(?:\d+\.?\d*|\.\d+)"
892
+ _symop_term = rf"{_symop_number}(?:/{_symop_number})?"
893
+ _rx_symop_translation = re.compile(rf"[+-]?{_symop_term}(?:[+-]{_symop_term})*")
894
+ _rx_symop_term = re.compile(rf"([+-]?)({_symop_number})(?:/({_symop_number}))?")
895
+
896
+
897
+ def _get_symop_translation(tpart, s):
898
+ # Sum the numeric terms in tpart without evaluating it as Python code.
899
+ # Only signed integers, decimals and fractions such as 1/2 are accepted.
900
+ emsg = (
901
+ f"Cannot read the symmetry operation {s!r} because {tpart!r} is not a number or a fraction. "
902
+ "Please correct the symmetry operations in the CIF file so that each one "
903
+ "looks like 'x,1/2-y,1/2+z' and try again."
904
+ )
905
+ if not tpart:
906
+ return 0.0
907
+ if not _rx_symop_translation.fullmatch(tpart):
908
+ raise StructureFormatError(emsg)
909
+ translation = 0.0
910
+ for sign, numerator, denominator in _rx_symop_term.findall(tpart):
911
+ value = float(numerator)
912
+ if denominator:
913
+ if float(denominator) == 0:
914
+ raise StructureFormatError(emsg)
915
+ value /= float(denominator)
916
+ translation += -value if sign == "-" else value
917
+ return translation
918
+
919
+
891
920
  @deprecated(getSymOp_deprecation_msg)
892
921
  def getSymOp(s):
893
922
  """This function has been deprecated and will be removed in version
@@ -910,6 +939,11 @@ def get_symop(s):
910
939
  -------
911
940
  SymOp
912
941
  Instance of `SymOp`.
942
+
943
+ Raises
944
+ ------
945
+ StructureFormatError
946
+ The translation part of the formula is not a number or a fraction.
913
947
  """
914
948
  from diffpy.structure.spacegroups import SymOp
915
949
 
@@ -922,7 +956,7 @@ def get_symop(s):
922
956
  for Rpart in eqparts[1::2]:
923
957
  R[i, :] += symvec[Rpart.lower()]
924
958
  for tpart in eqparts[::2]:
925
- t[i] += eval("1.0*%s+0" % tpart)
959
+ t[i] += _get_symop_translation(tpart, s)
926
960
  t -= numpy.floor(t)
927
961
  rv = SymOp(R, t)
928
962
  return rv
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.4
2
2
  Name: diffpy.structure
3
- Version: 3.5.0rc0
3
+ Version: 3.5.1
4
4
  Summary: Crystal structure container and parsers for structure formats.
5
5
  Author-email: Simon Billinge <sbillinge@ucsb.edu>
6
6
  Maintainer-email: Simon Billinge <sbillinge@ucsb.edu>
@@ -24,7 +24,7 @@ diffpy/structure/expansion/shapeutils.py,sha256=CY68_haUj-oCeyi-sYm1YNex6nbD0p-W
24
24
  diffpy/structure/expansion/supercell_mod.py,sha256=p52NwU85-gjiqgGpy80uGEC9nQaagppteaddR1ibkqI,2710
25
25
  diffpy/structure/parsers/__init__.py,sha256=0xFNOdp6WWFXkMZinqsG3TfoENMezJBMSrOOP65RYL8,4018
26
26
  diffpy/structure/parsers/p_auto.py,sha256=I86cRCHUcCKNKTqqBoQm59V2wY3yKox4fGqvCIPbD5E,7579
27
- diffpy/structure/parsers/p_cif.py,sha256=nRo9yJo1_J62H-hM7Dleok-vEqaJ8jbbs0J1Ab8IGX0,31643
27
+ diffpy/structure/parsers/p_cif.py,sha256=rQkcANW3u4CUQA6_rEb4U0fNVwn3b_kuHFSwbTqw71Q,32967
28
28
  diffpy/structure/parsers/p_discus.py,sha256=s8XltmjDLSzck6aRg1a-alaZaOEk5FJ72kePf916iKg,14829
29
29
  diffpy/structure/parsers/p_pdb.py,sha256=yGchhZ1nK-vpIyUkNiQhN11Wvnm5PFgiz7ObsQfj1vI,16982
30
30
  diffpy/structure/parsers/p_pdffit.py,sha256=npCgPrZHl-BgC5ZeWvDt3i7ZesGY8swm_QNuBSemlJo,12232
@@ -34,12 +34,12 @@ diffpy/structure/parsers/p_xcfg.py,sha256=9IsY69Q84GMvpYK0MUHKYRL6AsZfeNjdMWoB1x
34
34
  diffpy/structure/parsers/p_xyz.py,sha256=Tokue2aZLpX4-ooLZNBeQp7GHA6-mOcBcDD5o5JabhE,6343
35
35
  diffpy/structure/parsers/parser_index_mod.py,sha256=QkHxjvzRDJFnvP8HV5Sakoc2wxDwfF5cH0wzYpeDkVA,3056
36
36
  diffpy/structure/parsers/structureparser.py,sha256=EF1_UUkmOJ0yCn6hyixQy1esw3o-oc2a-h7mlDoYAiY,3648
37
- diffpy_structure-3.5.0rc0.dist-info/licenses/AUTHORS.rst,sha256=PH7xKOE6eZ60_LSn4IugF1w-9O2TWHJBBBC6WuiBXIg,255
38
- diffpy_structure-3.5.0rc0.dist-info/licenses/LICENSE-DANSE.rst,sha256=E0neMudgE7FONOlma0wrXZuSJktjv6WAzfBmEMRS1d8,2173
39
- diffpy_structure-3.5.0rc0.dist-info/licenses/LICENSE-pymmlib.rst,sha256=9RJGn2ZWB4NaWRh8AE8nefdlKDEENs0EBFBk3D2YAas,9591
40
- diffpy_structure-3.5.0rc0.dist-info/licenses/LICENSE.rst,sha256=pMvkBXH7zWETW6us7GcnihJG97qfoSlpHg4uwWqxUpg,6111
41
- diffpy_structure-3.5.0rc0.dist-info/METADATA,sha256=oJK64daY0uO4vOaoNZEqupXFTtZG7b5RlerjtaWfbDk,8641
42
- diffpy_structure-3.5.0rc0.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
43
- diffpy_structure-3.5.0rc0.dist-info/entry_points.txt,sha256=Ox2C-8sANvYxmDVmgBo1qwlPj4YeWFjlJyhDgIm0X-Y,63
44
- diffpy_structure-3.5.0rc0.dist-info/top_level.txt,sha256=34qLZyi9mxikpHepVDTMHrrNbe8VoOuz3ShYeiWA7KA,7
45
- diffpy_structure-3.5.0rc0.dist-info/RECORD,,
37
+ diffpy_structure-3.5.1.dist-info/licenses/AUTHORS.rst,sha256=PH7xKOE6eZ60_LSn4IugF1w-9O2TWHJBBBC6WuiBXIg,255
38
+ diffpy_structure-3.5.1.dist-info/licenses/LICENSE-DANSE.rst,sha256=E0neMudgE7FONOlma0wrXZuSJktjv6WAzfBmEMRS1d8,2173
39
+ diffpy_structure-3.5.1.dist-info/licenses/LICENSE-pymmlib.rst,sha256=9RJGn2ZWB4NaWRh8AE8nefdlKDEENs0EBFBk3D2YAas,9591
40
+ diffpy_structure-3.5.1.dist-info/licenses/LICENSE.rst,sha256=pMvkBXH7zWETW6us7GcnihJG97qfoSlpHg4uwWqxUpg,6111
41
+ diffpy_structure-3.5.1.dist-info/METADATA,sha256=Fw2sxYZWnyW8eJYi7FZuvu5bcbNf5LENnSxlNv8P7_Q,8638
42
+ diffpy_structure-3.5.1.dist-info/WHEEL,sha256=mOdXR9C3wMVov7cSY8PY-XCzo3SmmWCHvGQr5csJoao,91
43
+ diffpy_structure-3.5.1.dist-info/entry_points.txt,sha256=Ox2C-8sANvYxmDVmgBo1qwlPj4YeWFjlJyhDgIm0X-Y,63
44
+ diffpy_structure-3.5.1.dist-info/top_level.txt,sha256=34qLZyi9mxikpHepVDTMHrrNbe8VoOuz3ShYeiWA7KA,7
45
+ diffpy_structure-3.5.1.dist-info/RECORD,,
@@ -1,5 +1,5 @@
1
1
  Wheel-Version: 1.0
2
- Generator: setuptools (84.0.0)
2
+ Generator: setuptools (84.2.1)
3
3
  Root-Is-Purelib: true
4
4
  Tag: py3-none-any
5
5