Skip to content

Commit 4e3f684

Browse files
[pre-commit.ci] auto fixes from pre-commit hooks
1 parent 31fa572 commit 4e3f684

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+13706
-11885
lines changed

devutils/makesdist

Lines changed: 22 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -1,51 +1,57 @@
11
#!/usr/bin/env python
22

3-
'''Create source distribution tar.gz archive, where each file belongs
3+
"""Create source distribution tar.gz archive, where each file belongs
44
to a root user and modification time is set to the git commit time.
5-
'''
5+
"""
66

7-
import sys
7+
import glob
8+
import gzip
89
import os
910
import subprocess
10-
import glob
11+
import sys
1112
import tarfile
12-
import gzip
1313

1414
BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__)))
1515
sys.path.insert(0, BASEDIR)
1616

17-
from setup import versiondata, FALLBACK_VERSION
18-
timestamp = versiondata.getint('DEFAULT', 'timestamp')
17+
from setup import FALLBACK_VERSION, versiondata
1918

20-
vfb = versiondata.get('DEFAULT', 'version').split('.post')[0] + '.post0'
19+
timestamp = versiondata.getint("DEFAULT", "timestamp")
20+
21+
vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0"
2122
emsg = "Invalid FALLBACK_VERSION. Expected %r got %r."
2223
assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION)
2324

25+
2426
def inform(s):
2527
sys.stdout.write(s)
2628
sys.stdout.flush()
2729
return
2830

31+
2932
inform('Run "setup.py sdist --formats=tar" ')
30-
cmd_sdist = [sys.executable] + 'setup.py sdist --formats=tar'.split()
31-
ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, 'w'))
32-
if ec: sys.exit(ec)
33+
cmd_sdist = [sys.executable] + "setup.py sdist --formats=tar".split()
34+
ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, "w"))
35+
if ec:
36+
sys.exit(ec)
3337
inform("[done]\n")
3438

35-
tarname = max(glob.glob(BASEDIR + '/dist/*.tar'), key=os.path.getmtime)
39+
tarname = max(glob.glob(BASEDIR + "/dist/*.tar"), key=os.path.getmtime)
3640

3741
tfin = tarfile.open(tarname)
38-
fpout = gzip.GzipFile(tarname + '.gz', 'w', mtime=0)
39-
tfout = tarfile.open(fileobj=fpout, mode='w')
42+
fpout = gzip.GzipFile(tarname + ".gz", "w", mtime=0)
43+
tfout = tarfile.open(fileobj=fpout, mode="w")
44+
4045

4146
def fixtarinfo(tinfo):
4247
tinfo.uid = tinfo.gid = 0
43-
tinfo.uname = tinfo.gname = 'root'
48+
tinfo.uname = tinfo.gname = "root"
4449
tinfo.mtime = timestamp
4550
tinfo.mode &= ~0o022
4651
return tinfo
4752

48-
inform('Filter %s --> %s.gz ' % (2 * (os.path.basename(tarname),)))
53+
54+
inform("Filter %s --> %s.gz " % (2 * (os.path.basename(tarname),)))
4955
for ti in tfin:
5056
tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti))
5157

devutils/sgtbx_extra_groups.py

Lines changed: 53 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,31 @@
11
#!/usr/bin/env python
22

3-
'''Quick and extremely dirty script for generating code for SpaceGroup that
3+
"""Quick and extremely dirty script for generating code for SpaceGroup that
44
are defined in cctbx, but not in mmLib. It was used to generate module
55
sgtbxspacegroups.
66
77
This is a utility script that should not be included with code distribution.
88
99
Not to be included with code distributions.
10-
'''
10+
"""
1111

1212

13-
import re
1413
import math
14+
import re
15+
1516
import numpy
16-
from diffpy.structure.spacegroups import SpaceGroup, SymOp
17-
from diffpy.structure.spacegroups import mmLibSpaceGroupList
18-
from diffpy.structure.spacegroups import IsSpaceGroupIdentifier
1917
from cctbx import sgtbx
2018

19+
from diffpy.structure.spacegroups import IsSpaceGroupIdentifier, SpaceGroup, SymOp, mmLibSpaceGroupList
20+
21+
2122
def tupleToSGArray(tpl):
2223
if not _rtarrays:
2324
import diffpy.structure.SpaceGroups as sgmod
25+
2426
for n in dir(sgmod):
25-
if not n.startswith('Rot_') and not n.startswith('Tr_'): continue
27+
if not n.startswith("Rot_") and not n.startswith("Tr_"):
28+
continue
2629
a = getattr(sgmod, n)
2730
t = tuple(a.flatten())
2831
_rtarrays[t] = a
@@ -31,29 +34,30 @@ def tupleToSGArray(tpl):
3134
if tpl not in _rtarrays:
3235
_rtarrays[tpl] = numpy.array(tpl, dtype=float)
3336
return _rtarrays[tpl]
37+
38+
3439
_rtarrays = {}
3540

3641

3742
def mmSpaceGroupFromSymbol(symbol):
38-
"""Construct SpaceGroup instance from a string symbol using sgtbx data.
39-
"""
43+
"""Construct SpaceGroup instance from a string symbol using sgtbx data."""
4044
sginfo = sgtbx.space_group_info(symbol)
4145
symop_list = []
4246
symop_list = getSymOpList(sginfo.group())
4347
sgtype = sginfo.type()
4448
uhm = sgtype.lookup_symbol()
4549
sgsmbls = sgtbx.space_group_symbols(uhm)
4650
kw = {}
47-
kw['number'] = sgtype.number()
48-
kw['num_sym_equiv'] = len(symop_list)
49-
kw['num_primitive_sym_equiv'] = countUniqueRotations(symop_list)
50-
kw['short_name'] = sgsmbls.hermann_mauguin().replace(' ', '')
51+
kw["number"] = sgtype.number()
52+
kw["num_sym_equiv"] = len(symop_list)
53+
kw["num_primitive_sym_equiv"] = countUniqueRotations(symop_list)
54+
kw["short_name"] = sgsmbls.hermann_mauguin().replace(" ", "")
5155
pgt = sgsmbls.point_group_type()
52-
pgn = "PG" + re.sub(r'-(\d)', '\\1bar', pgt)
53-
kw['point_group_name'] = pgn
54-
kw['crystal_system'] = sgsmbls.crystal_system().upper()
55-
kw['pdb_name'] = sgsmbls.hermann_mauguin()
56-
kw['symop_list'] = symop_list
56+
pgn = "PG" + re.sub(r"-(\d)", "\\1bar", pgt)
57+
kw["point_group_name"] = pgn
58+
kw["crystal_system"] = sgsmbls.crystal_system().upper()
59+
kw["pdb_name"] = sgsmbls.hermann_mauguin()
60+
kw["symop_list"] = symop_list
5761
mmsg = SpaceGroup(**kw)
5862
return mmsg
5963

@@ -87,7 +91,8 @@ def countUniqueRotations(symop_list):
8791

8892

8993
def cmpSpaceGroups(sg0, sg1):
90-
if sg0 is sg1: return True
94+
if sg0 is sg1:
95+
return True
9196
s0 = hashMMSpaceGroup(sg0)
9297
s1 = hashMMSpaceGroup(sg1)
9398
return s0 == s1
@@ -100,6 +105,8 @@ def findEquivalentMMSpaceGroup(grp):
100105
_equivmmsg.setdefault(ssgn, sgn)
101106
ssg = hashSgtbxGroup(grp)
102107
return _equivmmsg.get(ssg)
108+
109+
103110
_equivmmsg = {}
104111

105112

@@ -112,24 +119,27 @@ def findEquivalentSgtbxSpaceGroup(sgmm):
112119
_equivsgtbx.setdefault(hgrp, grp)
113120
hgmm = hashMMSpaceGroup(sgmm)
114121
return _equivsgtbx.get(hgmm)
122+
123+
115124
_equivsgtbx = {}
116125

117126

118127
def hashMMSpaceGroup(sg):
119128
lines = [str(sg.number % 1000)] + sorted(map(str, sg.iter_symops()))
120-
s = '\n'.join(lines)
129+
s = "\n".join(lines)
121130
return s
122131

123132

124133
def hashSgtbxGroup(grp):
125134
n = grp.type().number()
126135
lines = [str(n)] + sorted(map(str, getSymOpList(grp)))
127-
s = '\n'.join(lines)
136+
s = "\n".join(lines)
128137
return s
129138

139+
130140
sgnumbers = [sg.number for sg in mmLibSpaceGroupList]
131141

132-
_SGsrc = '''\
142+
_SGsrc = """\
133143
sg%(number)i = SpaceGroup(
134144
number = %(number)i,
135145
num_sym_equiv = %(num_sym_equiv)i,
@@ -142,32 +152,37 @@ def hashSgtbxGroup(grp):
142152
@SYMOPS@
143153
]
144154
)
145-
'''
155+
"""
156+
146157

147158
def SGCode(mmsg):
148159
src0 = _SGsrc % mmsg.__dict__
149-
src1 = src0.replace('@SYMOPS@', SymOpsCode(mmsg))
160+
src1 = src0.replace("@SYMOPS@", SymOpsCode(mmsg))
150161
return src1
151162

152163

153164
def SymOpsCode(mmsg):
154-
lst = ["%8s%s," % ('', SymOpCode(op)) for op in mmsg.iter_symops()]
155-
src = '\n'.join(lst).strip()
165+
lst = ["%8s%s," % ("", SymOpCode(op)) for op in mmsg.iter_symops()]
166+
src = "\n".join(lst).strip()
156167
return src
157168

158169

159170
def SymOpCode(op):
160171
if not _rtnames:
161172
import diffpy.structure.SpaceGroups as sgmod
173+
162174
for n in dir(sgmod):
163-
if not n.startswith('Rot_') and not n.startswith('Tr_'): continue
175+
if not n.startswith("Rot_") and not n.startswith("Tr_"):
176+
continue
164177
a = getattr(sgmod, n)
165178
at = tuple(a.flatten())
166-
_rtnames[at] = 'sgmod.' + n
179+
_rtnames[at] = "sgmod." + n
167180
nR = _rtnames[tuple(op.R.flatten())]
168181
nt = _rtnames[tuple(op.t)]
169-
src = 'SymOp(%s, %s)' % (nR, nt)
182+
src = "SymOp(%s, %s)" % (nR, nt)
170183
return src
184+
185+
171186
_rtnames = {}
172187

173188

@@ -176,16 +191,20 @@ def main():
176191
for smbls in sgtbx.space_group_symbol_iterator():
177192
uhm = smbls.universal_hermann_mauguin()
178193
grp = sgtbx.space_group_info(uhm).group()
179-
if findEquivalentMMSpaceGroup(grp): continue
180-
shn = smbls.hermann_mauguin().replace(' ', '')
181-
if IsSpaceGroupIdentifier(shn): continue
194+
if findEquivalentMMSpaceGroup(grp):
195+
continue
196+
shn = smbls.hermann_mauguin().replace(" ", "")
197+
if IsSpaceGroupIdentifier(shn):
198+
continue
182199
sg = mmSpaceGroupFromSymbol(uhm)
183200
hsg = hashMMSpaceGroup(sg)
184-
if hsg in duplicates: continue
201+
if hsg in duplicates:
202+
continue
185203
adjustMMSpaceGroupNumber(sg)
186204
duplicates.add(hsg)
187205
print(SGCode(sg))
188206
return
189207

190-
if __name__ == '__main__':
208+
209+
if __name__ == "__main__":
191210
main()

doc/source/api/diffpy.structure.applications.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ diffpy.structure.applications.anyeye module
2626
:members:
2727
:undoc-members:
2828
:show-inheritance:
29-

doc/source/api/diffpy.structure.apps.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -26,4 +26,3 @@ diffpy.structure.apps.anyeye module
2626
:members:
2727
:undoc-members:
2828
:show-inheritance:
29-

doc/source/api/diffpy.structure.expansion.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -34,4 +34,3 @@ diffpy.structure.expansion.supercell_mod module
3434
:members:
3535
:undoc-members:
3636
:show-inheritance:
37-

doc/source/api/diffpy.structure.parsers.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -90,4 +90,3 @@ diffpy.structure.parsers.p_xyz module
9090
:members:
9191
:undoc-members:
9292
:show-inheritance:
93-

doc/source/api/diffpy.structure.rst

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -117,4 +117,3 @@ diffpy.structure.sgtbxspacegroups module
117117
:members:
118118
:undoc-members:
119119
:show-inheritance:
120-

src/diffpy/Structure.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,6 @@
2929
import diffpy.structure._legacy_importer
3030

3131
# replace this module with the new one
32-
sys.modules['diffpy.Structure'] = diffpy.structure
32+
sys.modules["diffpy.Structure"] = diffpy.structure
3333

3434
# End of file

src/diffpy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,4 +21,3 @@
2121
__path__ = extend_path(__path__, __name__)
2222

2323
# End of file
24-

src/diffpy/structure/__init__.py

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -27,12 +27,11 @@
2727

2828
# Interface definitions ------------------------------------------------------
2929

30-
from diffpy.structure.structureerrors import (StructureFormatError,
31-
LatticeError, SymmetryError)
3230
from diffpy.structure.atom import Atom
3331
from diffpy.structure.lattice import Lattice
34-
from diffpy.structure.structure import Structure
3532
from diffpy.structure.pdffitstructure import PDFFitStructure
33+
from diffpy.structure.structure import Structure
34+
from diffpy.structure.structureerrors import LatticeError, StructureFormatError, SymmetryError
3635

3736
# obtain version information
3837

@@ -43,7 +42,8 @@
4342

4443
# top level routines
4544

46-
def loadStructure(filename, fmt='auto', **kw):
45+
46+
def loadStructure(filename, fmt="auto", **kw):
4747
"""
4848
Load new structure object from the specified file.
4949
@@ -69,13 +69,14 @@ def loadStructure(filename, fmt='auto', **kw):
6969
and 'discus' formats.
7070
"""
7171
from diffpy.structure.parsers import getParser
72+
7273
p = getParser(fmt, **kw)
7374
rv = p.parseFile(filename)
7475
return rv
7576

77+
7678
# silence pyflakes checker
77-
assert (StructureFormatError and
78-
LatticeError and SymmetryError)
79+
assert StructureFormatError and LatticeError and SymmetryError
7980
assert Atom
8081
assert Lattice
8182
assert Structure

0 commit comments

Comments
 (0)