Skip to content

Commit 68d57e4

Browse files
authored
Merge pull request #73 from bobleesj/cookie-black
Run black . without any manual modification
2 parents 58a94de + 0540413 commit 68d57e4

File tree

110 files changed

+1907
-1818
lines changed

Some content is hidden

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

110 files changed

+1907
-1818
lines changed

doc/examples/coreshellnp.py

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,7 @@ def makeRecipe(stru1, stru2, datname):
7171
# phases, we implicitly assume that the core-shell correlations contribute
7272
# very little to the PDF.
7373
from diffpy.srfit.pdf.characteristicfunctions import shellCF, sphericalCF
74+
7475
contribution.registerFunction(sphericalCF, name="f_CdS")
7576
contribution.registerFunction(shellCF, name="f_ZnS")
7677

@@ -137,10 +138,11 @@ def plotResults(recipe):
137138
diff = g - gcalc + diffzero
138139

139140
import pylab
140-
pylab.plot(r, g, 'bo', label="G(r) Data")
141-
pylab.plot(r, gcalc, 'r-', label="G(r) Fit")
142-
pylab.plot(r, diff, 'g-', label="G(r) diff")
143-
pylab.plot(r, diffzero, 'k-')
141+
142+
pylab.plot(r, g, "bo", label="G(r) Data")
143+
pylab.plot(r, gcalc, "r-", label="G(r) Fit")
144+
pylab.plot(r, diff, "g-", label="G(r) diff")
145+
pylab.plot(r, diffzero, "k-")
144146
pylab.xlabel(r"$r (\AA)$")
145147
pylab.ylabel(r"$G (\AA^{-2})$")
146148
pylab.legend(loc=1)
@@ -162,6 +164,7 @@ def main():
162164
stru2 = loadCrystal(znsciffile)
163165
recipe = makeRecipe(stru1, stru2, data)
164166
from diffpy.srfit.fitbase.fithook import PlotFitHook
167+
165168
recipe.pushFitHook(PlotFitHook())
166169
recipe.fithooks[0].verbose = 3
167170

doc/examples/crystalpdf.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434

3535
####### Example Code
3636

37+
3738
def makeRecipe(ciffile, datname):
3839
"""Create a fitting recipe for crystalline PDF data."""
3940

@@ -50,7 +51,7 @@ def makeRecipe(ciffile, datname):
5051
parser = PDFParser()
5152
parser.parseFile(datname)
5253
profile.loadParsedData(parser)
53-
profile.setCalculationRange(xmax = 20)
54+
profile.setCalculationRange(xmax=20)
5455

5556
## The ProfileGenerator
5657
# The PDFGenerator is for configuring and calculating a PDF profile. Here,
@@ -69,7 +70,7 @@ def makeRecipe(ciffile, datname):
6970
# before.
7071
contribution = FitContribution("nickel")
7172
contribution.addProfileGenerator(generator)
72-
contribution.setProfile(profile, xname = "r")
73+
contribution.setProfile(profile, xname="r")
7374

7475
## Make the FitRecipe and add the FitContribution.
7576
recipe = FitRecipe()
@@ -92,6 +93,7 @@ def makeRecipe(ciffile, datname):
9293
# documentation for more details. The 'constrainAsSpaceGroup' method may
9394
# create new Parameters, which it returns in a SpaceGroupParameters object.
9495
from diffpy.srfit.structure import constrainAsSpaceGroup
96+
9597
sgpars = constrainAsSpaceGroup(phase, "Fm-3m")
9698

9799
# The SpaceGroupParameters object returned by 'constrainAsSpaceGroup' holds
@@ -121,6 +123,7 @@ def makeRecipe(ciffile, datname):
121123
# Give the recipe away so it can be used!
122124
return recipe
123125

126+
124127
def plotResults(recipe):
125128
"""Plot the results contained within a refined FitRecipe."""
126129

@@ -132,19 +135,20 @@ def plotResults(recipe):
132135
diff = g - gcalc + diffzero
133136

134137
import pylab
135-
pylab.plot(r,g,'bo',label="G(r) Data")
136-
pylab.plot(r, gcalc,'r-',label="G(r) Fit")
137-
pylab.plot(r,diff,'g-',label="G(r) diff")
138-
pylab.plot(r,diffzero,'k-')
138+
139+
pylab.plot(r, g, "bo", label="G(r) Data")
140+
pylab.plot(r, gcalc, "r-", label="G(r) Fit")
141+
pylab.plot(r, diff, "g-", label="G(r) diff")
142+
pylab.plot(r, diffzero, "k-")
139143
pylab.xlabel(r"$r (\AA)$")
140144
pylab.ylabel(r"$G (\AA^{-2})$")
141145
pylab.legend(loc=1)
142146

143147
pylab.show()
144148
return
145149

146-
if __name__ == "__main__":
147150

151+
if __name__ == "__main__":
148152
# Make the data and the recipe
149153
ciffile = "data/ni.cif"
150154
data = "data/ni-q27r100-neutron.gr"

doc/examples/crystalpdfall.py

Lines changed: 36 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -28,24 +28,26 @@
2828

2929
####### Example Code
3030

31+
3132
def makeProfile(datafile):
3233
"""Make an place data within a Profile."""
3334
profile = Profile()
3435
parser = PDFParser()
3536
parser.parseFile(datafile)
3637
profile.loadParsedData(parser)
37-
profile.setCalculationRange(xmax = 20)
38+
profile.setCalculationRange(xmax=20)
3839
return profile
3940

41+
4042
def makeContribution(name, generator, profile):
4143
"""Make a FitContribution and add a generator and profile."""
4244
contribution = FitContribution(name)
4345
contribution.addProfileGenerator(generator)
44-
contribution.setProfile(profile, xname = "r")
46+
contribution.setProfile(profile, xname="r")
4547
return contribution
4648

47-
def makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si,
48-
xdata_sini):
49+
50+
def makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si, xdata_sini):
4951
"""Create a fitting recipe for crystalline PDF data."""
5052

5153
## The Profiles
@@ -81,8 +83,7 @@ def makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si,
8183
xcontribution_ni = makeContribution("xnickel", xgenerator_ni, xprofile_ni)
8284
xcontribution_si = makeContribution("xsilicon", xgenerator_si, xprofile_si)
8385
ncontribution_ni = makeContribution("nnickel", ngenerator_ni, nprofile_ni)
84-
xcontribution_sini = makeContribution("xsini", xgenerator_sini_ni,
85-
xprofile_sini)
86+
xcontribution_sini = makeContribution("xsini", xgenerator_sini_ni, xprofile_sini)
8687
xcontribution_sini.addProfileGenerator(xgenerator_sini_si)
8788
xcontribution_sini.setEquation("scale * (xG_sini_ni + xG_sini_si)")
8889

@@ -101,22 +102,22 @@ def makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si,
101102

102103
# Now we vary and constrain Parameters as before.
103104
for par in phase_ni.sgpars:
104-
recipe.addVar(par, name = par.name + "_ni")
105+
recipe.addVar(par, name=par.name + "_ni")
105106
delta2_ni = recipe.newVar("delta2_ni", 2.5)
106107
recipe.constrain(xgenerator_ni.delta2, delta2_ni)
107108
recipe.constrain(ngenerator_ni.delta2, delta2_ni)
108109
recipe.constrain(xgenerator_sini_ni.delta2, delta2_ni)
109110

110111
for par in phase_si.sgpars:
111-
recipe.addVar(par, name = par.name + "_si")
112+
recipe.addVar(par, name=par.name + "_si")
112113
delta2_si = recipe.newVar("delta2_si", 2.5)
113114
recipe.constrain(xgenerator_si.delta2, delta2_si)
114115
recipe.constrain(xgenerator_sini_si.delta2, delta2_si)
115116

116117
# Now the experimental parameters
117-
recipe.addVar(xgenerator_ni.scale, name = "xscale_ni")
118-
recipe.addVar(xgenerator_si.scale, name = "xscale_si")
119-
recipe.addVar(ngenerator_ni.scale, name = "nscale_ni")
118+
recipe.addVar(xgenerator_ni.scale, name="xscale_ni")
119+
recipe.addVar(xgenerator_si.scale, name="xscale_si")
120+
recipe.addVar(ngenerator_ni.scale, name="nscale_ni")
120121
recipe.addVar(xcontribution_sini.scale, 1.0, "xscale_sini")
121122
recipe.newVar("pscale_sini_ni", 0.8)
122123
recipe.constrain(xgenerator_sini_ni.scale, "pscale_sini_ni")
@@ -133,6 +134,7 @@ def makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si,
133134
# Give the recipe away so it can be used!
134135
return recipe
135136

137+
136138
def plotResults(recipe):
137139
"""Plot the results contained within a refined FitRecipe."""
138140

@@ -141,67 +143,67 @@ def plotResults(recipe):
141143
xr_ni = xnickel.profile.x
142144
xg_ni = xnickel.profile.y
143145
xgcalc_ni = xnickel.profile.ycalc
144-
xdiffzero_ni = -0.8 * max(xg_ni) * numpy.ones_like(xg_ni)
146+
xdiffzero_ni = -0.8 * max(xg_ni) * numpy.ones_like(xg_ni)
145147
xdiff_ni = xg_ni - xgcalc_ni + xdiffzero_ni
146148

147149
xsilicon = recipe.xsilicon
148150
xr_si = xsilicon.profile.x
149151
xg_si = xsilicon.profile.y
150152
xgcalc_si = xsilicon.profile.ycalc
151-
xdiffzero_si = -0.8 * max(xg_si) * numpy.ones_like(xg_si)
153+
xdiffzero_si = -0.8 * max(xg_si) * numpy.ones_like(xg_si)
152154
xdiff_si = xg_si - xgcalc_si + xdiffzero_si
153155

154156
nnickel = recipe.nnickel
155157
nr_ni = nnickel.profile.x
156158
ng_ni = nnickel.profile.y
157159
ngcalc_ni = nnickel.profile.ycalc
158-
ndiffzero_ni = -0.8 * max(ng_ni) * numpy.ones_like(ng_ni)
160+
ndiffzero_ni = -0.8 * max(ng_ni) * numpy.ones_like(ng_ni)
159161
ndiff_ni = ng_ni - ngcalc_ni + ndiffzero_ni
160162

161163
xsini = recipe.xsini
162164
xr_sini = xsini.profile.x
163165
xg_sini = xsini.profile.y
164166
xgcalc_sini = xsini.profile.ycalc
165-
xdiffzero_sini = -0.8 * max(xg_sini) * numpy.ones_like(xg_sini)
167+
xdiffzero_sini = -0.8 * max(xg_sini) * numpy.ones_like(xg_sini)
166168
xdiff_sini = xg_sini - xgcalc_sini + xdiffzero_sini
167169

168-
169170
import pylab
171+
170172
pylab.subplot(2, 2, 1)
171-
pylab.plot(xr_ni,xg_ni,'bo',label="G(r) x-ray nickel Data")
172-
pylab.plot(xr_ni,xgcalc_ni,'r-',label="G(r) x-ray nickel Fit")
173-
pylab.plot(xr_ni,xdiff_ni,'g-',label="G(r) x-ray nickel diff")
174-
pylab.plot(xr_ni,xdiffzero_ni,'k-')
173+
pylab.plot(xr_ni, xg_ni, "bo", label="G(r) x-ray nickel Data")
174+
pylab.plot(xr_ni, xgcalc_ni, "r-", label="G(r) x-ray nickel Fit")
175+
pylab.plot(xr_ni, xdiff_ni, "g-", label="G(r) x-ray nickel diff")
176+
pylab.plot(xr_ni, xdiffzero_ni, "k-")
175177
pylab.xlabel(r"$r (\AA)$")
176178
pylab.ylabel(r"$G (\AA^{-2})$")
177179
pylab.legend(loc=1)
178180

179181
pylab.subplot(2, 2, 2)
180-
pylab.plot(xr_si,xg_si,'bo',label="G(r) x-ray silicon Data")
181-
pylab.plot(xr_si,xgcalc_si,'r-',label="G(r) x-ray silicon Fit")
182-
pylab.plot(xr_si,xdiff_si,'g-',label="G(r) x-ray silicon diff")
183-
pylab.plot(xr_si,xdiffzero_si,'k-')
182+
pylab.plot(xr_si, xg_si, "bo", label="G(r) x-ray silicon Data")
183+
pylab.plot(xr_si, xgcalc_si, "r-", label="G(r) x-ray silicon Fit")
184+
pylab.plot(xr_si, xdiff_si, "g-", label="G(r) x-ray silicon diff")
185+
pylab.plot(xr_si, xdiffzero_si, "k-")
184186
pylab.legend(loc=1)
185187

186188
pylab.subplot(2, 2, 3)
187-
pylab.plot(nr_ni,ng_ni,'bo',label="G(r) neutron nickel Data")
188-
pylab.plot(nr_ni,ngcalc_ni,'r-',label="G(r) neutron nickel Fit")
189-
pylab.plot(nr_ni,ndiff_ni,'g-',label="G(r) neutron nickel diff")
190-
pylab.plot(nr_ni,ndiffzero_ni,'k-')
189+
pylab.plot(nr_ni, ng_ni, "bo", label="G(r) neutron nickel Data")
190+
pylab.plot(nr_ni, ngcalc_ni, "r-", label="G(r) neutron nickel Fit")
191+
pylab.plot(nr_ni, ndiff_ni, "g-", label="G(r) neutron nickel diff")
192+
pylab.plot(nr_ni, ndiffzero_ni, "k-")
191193
pylab.legend(loc=1)
192194

193195
pylab.subplot(2, 2, 4)
194-
pylab.plot(xr_sini,xg_sini,'bo',label="G(r) x-ray sini Data")
195-
pylab.plot(xr_sini,xgcalc_sini,'r-',label="G(r) x-ray sini Fit")
196-
pylab.plot(xr_sini,xdiff_sini,'g-',label="G(r) x-ray sini diff")
197-
pylab.plot(xr_sini,xdiffzero_sini,'k-')
196+
pylab.plot(xr_sini, xg_sini, "bo", label="G(r) x-ray sini Data")
197+
pylab.plot(xr_sini, xgcalc_sini, "r-", label="G(r) x-ray sini Fit")
198+
pylab.plot(xr_sini, xdiff_sini, "g-", label="G(r) x-ray sini diff")
199+
pylab.plot(xr_sini, xdiffzero_sini, "k-")
198200
pylab.legend(loc=1)
199201

200202
pylab.show()
201203
return
202204

203-
if __name__ == "__main__":
204205

206+
if __name__ == "__main__":
205207
# Make the data and the recipe
206208
ciffile_ni = "data/ni.cif"
207209
ciffile_si = "data/si.cif"
@@ -211,8 +213,7 @@ def plotResults(recipe):
211213
xdata_sini = "data/si90ni10-q27r60-xray.gr"
212214

213215
# Make the recipe
214-
recipe = makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si,
215-
xdata_sini)
216+
recipe = makeRecipe(ciffile_ni, ciffile_si, xdata_ni, ndata_ni, xdata_si, xdata_sini)
216217

217218
# Optimize
218219
scipyOptimize(recipe)

doc/examples/crystalpdfobjcryst.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -29,6 +29,7 @@
2929

3030
####### Example Code
3131

32+
3233
def makeRecipe(ciffile, datname):
3334
"""Create a fitting recipe for crystalline PDF data."""
3435

@@ -43,7 +44,7 @@ def makeRecipe(ciffile, datname):
4344
parser = PDFParser()
4445
parser.parseFile(datname)
4546
profile.loadParsedData(parser)
46-
profile.setCalculationRange(xmax = 20)
47+
profile.setCalculationRange(xmax=20)
4748

4849
## The ProfileGenerator
4950
# This time we use the CreateCrystalFromCIF method of pyobjcryst.crystal to
@@ -57,7 +58,7 @@ def makeRecipe(ciffile, datname):
5758
## The FitContribution
5859
contribution = FitContribution("nickel")
5960
contribution.addProfileGenerator(generator)
60-
contribution.setProfile(profile, xname = "r")
61+
contribution.setProfile(profile, xname="r")
6162

6263
# Make the FitRecipe and add the FitContribution.
6364
recipe = FitRecipe()
@@ -86,7 +87,7 @@ def makeRecipe(ciffile, datname):
8687
for par in phase.sgpars:
8788
recipe.addVar(par)
8889
# set the initial thermal factor to a non-zero value
89-
assert hasattr(recipe, 'B11_0')
90+
assert hasattr(recipe, "B11_0")
9091
recipe.B11_0 = 0.1
9192

9293
# We now select non-structural parameters to refine.
@@ -100,8 +101,8 @@ def makeRecipe(ciffile, datname):
100101
# Give the recipe away so it can be used!
101102
return recipe
102103

103-
if __name__ == "__main__":
104104

105+
if __name__ == "__main__":
105106
# Make the data and the recipe
106107
ciffile = "data/si.cif"
107108
data = "data/si-q27r60-xray.gr"

0 commit comments

Comments
 (0)