Skip to content

Commit 6198d35

Browse files
committed
black autofix
1 parent f353243 commit 6198d35

Some content is hidden

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

55 files changed

+1673
-1757
lines changed

conda-recipe/run_test.py

+1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
#!/usr/bin/env python
22

33
import diffpy.srreal.tests
4+
45
assert diffpy.srreal.tests.test().wasSuccessful()

devutils/tunePeakPrecision.py

+39-33
Original file line numberDiff line numberDiff line change
@@ -30,11 +30,12 @@
3030
from diffpy.structure import Structure
3131
from diffpy.srreal.pdf_ext import PDFCalculator
3232
import diffpy.pdffit2
33+
3334
# make PdfFit silent
34-
diffpy.pdffit2.redirect_stdout(open('/dev/null', 'w'))
35+
diffpy.pdffit2.redirect_stdout(open("/dev/null", "w"))
3536

3637
# define nickel structure data
37-
nickel_discus_data = '''
38+
nickel_discus_data = """
3839
title Ni
3940
spcgr P1
4041
cell 3.523870, 3.523870, 3.523870, 90.000000, 90.000000, 90.000000
@@ -44,10 +45,10 @@
4445
NI 0.00000000 0.50000000 0.50000000 0.1000
4546
NI 0.50000000 0.00000000 0.50000000 0.1000
4647
NI 0.50000000 0.50000000 0.00000000 0.1000
47-
'''
48+
"""
4849

4950
nickel = Structure()
50-
nickel.readStr(nickel_discus_data, format='discus')
51+
nickel.readStr(nickel_discus_data, format="discus")
5152

5253

5354
def Gpdffit2(qmax):
@@ -59,7 +60,7 @@ def Gpdffit2(qmax):
5960
"""
6061
# calculate reference data using pdffit2
6162
pf2 = diffpy.pdffit2.PdfFit()
62-
pf2.alloc('X', qmax, 0.0, rmin, rmax, int((rmax - rmin) / rstep + 1))
63+
pf2.alloc("X", qmax, 0.0, rmin, rmax, int((rmax - rmin) / rstep + 1))
6364
pf2.add_structure(nickel)
6465
pf2.calc()
6566
rg = numpy.array((pf2.getR(), pf2.getpdf_fit()))
@@ -81,7 +82,7 @@ def Gsrreal(qmax, peakprecision=None):
8182
pdfcalc._setDoubleAttr("rmax", rmax + rstep * 1e-4)
8283
pdfcalc._setDoubleAttr("rstep", rstep)
8384
if peakprecision is not None:
84-
pdfcalc._setDoubleAttr('peakprecision', peakprecision)
85+
pdfcalc._setDoubleAttr("peakprecision", peakprecision)
8586
pdfcalc.eval(nickel)
8687
rg = numpy.array([pdfcalc.rgrid, pdfcalc.pdf])
8788
return rg
@@ -105,38 +106,39 @@ def comparePDFCalculators(qmax, peakprecision=None):
105106
t0, t1 -- CPU times used by pdffit2 and PDFCalculator calls
106107
"""
107108
rv = {}
108-
rv['qmax'] = qmax
109-
rv['peakprecision'] = (peakprecision is None and
110-
PDFCalculator()._getDoubleAttr('peakprecision') or peakprecision)
109+
rv["qmax"] = qmax
110+
rv["peakprecision"] = (
111+
peakprecision is None and PDFCalculator()._getDoubleAttr("peakprecision") or peakprecision
112+
)
111113
ttic = time.clock()
112114
rg0 = Gpdffit2(qmax)
113115
ttoc = time.clock()
114-
rv['r'] = rg0[0]
115-
rv['g0'] = rg0[1]
116-
rv['t0'] = ttoc - ttic
116+
rv["r"] = rg0[0]
117+
rv["g0"] = rg0[1]
118+
rv["t0"] = ttoc - ttic
117119
ttic = time.clock()
118120
rg1 = Gsrreal(qmax, peakprecision)
119121
ttoc = time.clock()
120-
assert numpy.all(rv['r'] == rg1[0])
121-
rv['g1'] = rg1[1]
122-
rv['t1'] = ttoc - ttic
123-
rv['gdiff'] = rv['g0'] - rv['g1']
124-
rv['grmsd'] = numpy.sqrt(numpy.mean(rv['gdiff']**2))
122+
assert numpy.all(rv["r"] == rg1[0])
123+
rv["g1"] = rg1[1]
124+
rv["t1"] = ttoc - ttic
125+
rv["gdiff"] = rv["g0"] - rv["g1"]
126+
rv["grmsd"] = numpy.sqrt(numpy.mean(rv["gdiff"] ** 2))
125127
return rv
126128

127129

128130
def processCommandLineArguments():
129131
global qmax, peakprecision, createplot
130132
argc = len(sys.argv)
131-
if set(['-h', '--help']).intersection(sys.argv):
133+
if set(["-h", "--help"]).intersection(sys.argv):
132134
print(__doc__)
133135
sys.exit()
134136
if argc > 1:
135137
qmax = float(sys.argv[1])
136138
if argc > 2:
137139
peakprecision = float(sys.argv[2])
138140
if argc > 3:
139-
createplot = sys.argv[3].lower() in ('y', 'yes', '1', 'true')
141+
createplot = sys.argv[3].lower() in ("y", "yes", "1", "true")
140142
return
141143

142144

@@ -148,37 +150,41 @@ def plotComparison(cmpdata):
148150
No return value.
149151
"""
150152
import pylab
153+
151154
pylab.clf()
152155
pylab.subplot(211)
153-
pylab.title('qmax=%(qmax)g peakprecision=%(peakprecision)g' % cmpdata)
154-
pylab.ylabel('G')
155-
r = cmpdata['r']
156-
g0 = cmpdata['g0']
157-
g1 = cmpdata['g1']
158-
gdiff = cmpdata['gdiff']
156+
pylab.title("qmax=%(qmax)g peakprecision=%(peakprecision)g" % cmpdata)
157+
pylab.ylabel("G")
158+
r = cmpdata["r"]
159+
g0 = cmpdata["g0"]
160+
g1 = cmpdata["g1"]
161+
gdiff = cmpdata["gdiff"]
159162
pylab.plot(r, g0, r, g1)
160163
pylab.subplot(212)
161-
pylab.plot(r, gdiff, 'r')
164+
pylab.plot(r, gdiff, "r")
162165
slope = numpy.sum(r * gdiff) / numpy.sum(r**2)
163-
pylab.plot(r, slope * r, '--')
164-
pylab.xlabel('r')
165-
pylab.ylabel('Gdiff')
166-
pylab.title('slope = %g' % slope)
166+
pylab.plot(r, slope * r, "--")
167+
pylab.xlabel("r")
168+
pylab.ylabel("Gdiff")
169+
pylab.title("slope = %g" % slope)
167170
pylab.draw()
168171
return
169172

170173

171174
def main():
172175
processCommandLineArguments()
173176
cmpdata = comparePDFCalculators(qmax, peakprecision)
174-
print(("qmax = %(qmax)g pkprec = %(peakprecision)g " +
175-
"grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f") % cmpdata)
177+
print(
178+
("qmax = %(qmax)g pkprec = %(peakprecision)g " + "grmsd = %(grmsd)g t0 = %(t0).3f t1 = %(t1).3f")
179+
% cmpdata
180+
)
176181
if createplot:
177182
plotComparison(cmpdata)
178183
import pylab
184+
179185
pylab.show()
180186
return
181187

182188

183-
if __name__ == '__main__':
189+
if __name__ == "__main__":
184190
main()

doc/manual/source/conf.py

+44-43
Original file line numberDiff line numberDiff line change
@@ -19,11 +19,11 @@
1919
# If extensions (or modules to document with autodoc) are in another directory,
2020
# add these directories to sys.path here. If the directory is relative to the
2121
# documentation root, use os.path.abspath to make it absolute, like shown here.
22-
#sys.path.insert(0, os.path.abspath('.'))
23-
sys.path.insert(0, os.path.abspath('../../..'))
22+
# sys.path.insert(0, os.path.abspath('.'))
23+
sys.path.insert(0, os.path.abspath("../../.."))
2424

2525
# abbreviations
26-
ab_authors = u'Pavol Juhás, Christopher L. Farrow, Simon J.L. Billinge group'
26+
ab_authors = "Pavol Juhás, Christopher L. Farrow, Simon J.L. Billinge group"
2727

2828
# -- General configuration -----------------------------------------------------
2929

@@ -33,38 +33,39 @@
3333
# Add any Sphinx extension module names here, as strings. They can be extensions
3434
# coming with Sphinx (named 'sphinx.ext.*') or your custom ones.
3535
extensions = [
36-
'sphinx.ext.autodoc',
37-
'sphinx.ext.coverage',
38-
'sphinx.ext.napoleon',
39-
'sphinx.ext.intersphinx',
40-
'm2r',
36+
"sphinx.ext.autodoc",
37+
"sphinx.ext.coverage",
38+
"sphinx.ext.napoleon",
39+
"sphinx.ext.intersphinx",
40+
"m2r",
4141
]
4242

4343
# Add any paths that contain templates here, relative to this directory.
44-
templates_path = ['_templates']
44+
templates_path = ["_templates"]
4545

4646
# The suffix(es) of source filenames.
4747
# You can specify multiple suffix as a list of string:
4848
#
49-
source_suffix = ['.rst', '.md']
49+
source_suffix = [".rst", ".md"]
5050

5151
# The encoding of source files.
5252
# source_encoding = 'utf-8-sig'
5353

5454
# The master toctree document.
55-
master_doc = 'index'
55+
master_doc = "index"
5656

5757
# General information about the project.
58-
project = 'diffpy.srreal'
59-
copyright = '%Y, Brookhaven National Laboratory'
58+
project = "diffpy.srreal"
59+
copyright = "%Y, Brookhaven National Laboratory"
6060

6161
# The version info for the project you're documenting, acts as replacement for
6262
# |version| and |release|, also used in various other places throughout the
6363
# built documents.
6464
from setup import versiondata
65-
fullversion = versiondata.get('DEFAULT', 'version')
65+
66+
fullversion = versiondata.get("DEFAULT", "version")
6667
# The short X.Y version.
67-
version = ''.join(fullversion.split('.post')[:1])
68+
version = "".join(fullversion.split(".post")[:1])
6869
# The full version, including alpha/beta/rc tags.
6970
release = fullversion
7071

@@ -75,13 +76,13 @@
7576
# There are two options for replacing |today|: either, you set today to some
7677
# non-false value, then it is used:
7778
# today = ''
78-
today_seconds = versiondata.getint('DEFAULT', 'timestamp')
79-
today = time.strftime('%B %d, %Y', time.localtime(today_seconds))
79+
today_seconds = versiondata.getint("DEFAULT", "timestamp")
80+
today = time.strftime("%B %d, %Y", time.localtime(today_seconds))
8081
year = today.split()[-1]
8182
# Else, today_fmt is used as the format for a strftime call.
8283
# today_fmt = '%B %d, %Y'
8384
# substitute YEAR in the copyright string
84-
copyright = copyright.replace('%Y', year)
85+
copyright = copyright.replace("%Y", year)
8586

8687
# List of patterns, relative to source directory, that match files and
8788
# directories to ignore when looking for source files.
@@ -102,10 +103,10 @@
102103
# show_authors = False
103104

104105
# The name of the Pygments (syntax highlighting) style to use.
105-
pygments_style = 'sphinx'
106+
pygments_style = "sphinx"
106107

107108
# A list of ignored prefixes for module index sorting.
108-
modindex_common_prefix = ['diffpy.srreal']
109+
modindex_common_prefix = ["diffpy.srreal"]
109110

110111
# Display all warnings for missing links.
111112
nitpicky = True
@@ -114,14 +115,14 @@
114115

115116
# The theme to use for HTML and HTML Help pages. See the documentation for
116117
# a list of builtin themes.
117-
html_theme = 'sphinx_py3doc_enhanced_theme'
118+
html_theme = "sphinx_py3doc_enhanced_theme"
118119

119120
# Theme options are theme-specific and customize the look and feel of a theme
120121
# further. For a list of options available for each theme, see the
121122
# documentation.
122123
html_theme_options = {
123-
'collapsiblesidebar' : 'true',
124-
'navigation_with_keys' : 'true',
124+
"collapsiblesidebar": "true",
125+
"navigation_with_keys": "true",
125126
}
126127

127128
# Add any paths that contain custom themes here, relative to this directory.
@@ -190,27 +191,24 @@
190191
# html_file_suffix = None
191192

192193
# Output file base name for HTML help builder.
193-
htmlhelp_basename = 'srrealdoc'
194+
htmlhelp_basename = "srrealdoc"
194195

195196

196197
# -- Options for LaTeX output --------------------------------------------------
197198

198199
latex_elements = {
199-
# The paper size ('letterpaper' or 'a4paper').
200-
# 'papersize': 'letterpaper',
201-
202-
# The font size ('10pt', '11pt' or '12pt').
203-
# 'pointsize': '10pt',
204-
205-
# Additional stuff for the LaTeX preamble.
206-
# 'preamble': '',
200+
# The paper size ('letterpaper' or 'a4paper').
201+
# 'papersize': 'letterpaper',
202+
# The font size ('10pt', '11pt' or '12pt').
203+
# 'pointsize': '10pt',
204+
# Additional stuff for the LaTeX preamble.
205+
# 'preamble': '',
207206
}
208207

209208
# Grouping the document tree into LaTeX files. List of tuples
210209
# (source start file, target name, title, author, documentclass [howto/manual]).
211210
latex_documents = [
212-
('index', 'diffpy.srreal.tex', 'diffpy.srreal Documentation',
213-
ab_authors, 'manual'),
211+
("index", "diffpy.srreal.tex", "diffpy.srreal Documentation", ab_authors, "manual"),
214212
]
215213

216214
# The name of an image file (relative to this directory) to place at the top of
@@ -238,10 +236,7 @@
238236

239237
# One entry per manual page. List of tuples
240238
# (source start file, name, description, authors, manual section).
241-
man_pages = [
242-
('index', 'diffpy.srreal', 'diffpy.srreal Documentation',
243-
ab_authors, 1)
244-
]
239+
man_pages = [("index", "diffpy.srreal", "diffpy.srreal Documentation", ab_authors, 1)]
245240

246241
# If true, show URL addresses after external links.
247242
# man_show_urls = False
@@ -253,9 +248,15 @@
253248
# (source start file, target name, title, author,
254249
# dir menu entry, description, category)
255250
texinfo_documents = [
256-
('index', 'diffpy.srreal', 'diffpy.srreal Documentation',
257-
ab_authors, 'diffpy.srreal', 'One line description of project.',
258-
'Miscellaneous'),
251+
(
252+
"index",
253+
"diffpy.srreal",
254+
"diffpy.srreal Documentation",
255+
ab_authors,
256+
"diffpy.srreal",
257+
"One line description of project.",
258+
"Miscellaneous",
259+
),
259260
]
260261

261262
# Documents to append as an appendix to all manuals.
@@ -270,6 +271,6 @@
270271

271272
# Example configuration for intersphinx: refer to the Python standard library.
272273
intersphinx_mapping = {
273-
'numpy': ('https://docs.scipy.org/doc/numpy', None),
274-
'python' : ('https://docs.python.org/3.7', None),
274+
"numpy": ("https://docs.scipy.org/doc/numpy", None),
275+
"python": ("https://docs.python.org/3.7", None),
275276
}

examples/compareC60PDFs.py

+5-4
Original file line numberDiff line numberDiff line change
@@ -11,13 +11,14 @@
1111
from diffpy.srreal.pdfcalculator import PDFCalculator, DebyePDFCalculator
1212

1313
mydir = os.path.dirname(os.path.abspath(sys.argv[0]))
14-
buckyfile = os.path.join(mydir, 'datafiles', 'C60bucky.stru')
14+
buckyfile = os.path.join(mydir, "datafiles", "C60bucky.stru")
1515

1616
# load C60 molecule as a diffpy.structure object
1717
bucky = Structure(filename=buckyfile)
18-
cfg = { 'qmax' : 25,
19-
'rmin' : 0,
20-
'rmax' : 10.001,
18+
cfg = {
19+
"qmax": 25,
20+
"rmin": 0,
21+
"rmax": 10.001,
2122
}
2223

2324
# calculate PDF by real-space summation

examples/compareC60PDFs_objcryst.py

+7-6
Original file line numberDiff line numberDiff line change
@@ -12,10 +12,10 @@
1212
from diffpy.srreal.pdfcalculator import PDFCalculator, DebyePDFCalculator
1313

1414
# load C60 molecule as a diffpy.structure object
15-
bucky_diffpy = Structure(filename='datafiles/C60bucky.stru')
15+
bucky_diffpy = Structure(filename="datafiles/C60bucky.stru")
1616

1717
# convert to an ObjCryst molecule
18-
c60 = Crystal(1, 1, 1, 'P1')
18+
c60 = Crystal(1, 1, 1, "P1")
1919
mc60 = Molecule(c60, "C60")
2020
c60.AddScatterer(mc60)
2121
# Create the scattering power object for the carbon atoms
@@ -26,10 +26,11 @@
2626
mc60.AddAtom(a.xyz_cartn[0], a.xyz_cartn[1], a.xyz_cartn[2], sp, cname)
2727

2828
# PDF configuration
29-
cfg = { 'qmax' : 25,
30-
'rmin' : 0,
31-
'rmax' : 10.001,
32-
'rstep' : 0.05,
29+
cfg = {
30+
"qmax": 25,
31+
"rmin": 0,
32+
"rmax": 10.001,
33+
"rstep": 0.05,
3334
}
3435

3536
# calculate PDF by real-space summation

0 commit comments

Comments
 (0)