Skip to content

Commit 9e7a7c8

Browse files
authored
Merge pull request #157 from cadenmyers13/fitrecipe-dep
deprecate: Deprecate remaining methods of `FitRecipe`
2 parents 31e9698 + 644cc97 commit 9e7a7c8

29 files changed

+394
-202
lines changed

docs/examples/coreshellnp.py

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -89,43 +89,47 @@ def makeRecipe(stru1, stru2, datname):
8989

9090
# Vary the inner radius and thickness of the shell. Constrain the core
9191
# diameter to twice the shell radius.
92-
recipe.addVar(contribution.radius, 15)
93-
recipe.addVar(contribution.thickness, 11)
92+
recipe.add_variable(contribution.radius, 15)
93+
recipe.add_variable(contribution.thickness, 11)
9494
recipe.constrain(contribution.psize, "2 * radius")
9595

9696
# Configure the fit variables
9797
# Start by configuring the scale factor and resolution factors.
9898
# We want the sum of the phase scale factors to be 1.
99-
recipe.newVar("scale_CdS", 0.7)
99+
recipe.create_new_variable("scale_CdS", 0.7)
100100
recipe.constrain(generator_cds.scale, "scale_CdS")
101101
recipe.constrain(generator_zns.scale, "1 - scale_CdS")
102102
# We also want the resolution factor to be the same on each.
103103

104104
# Vary the global scale as well.
105-
recipe.addVar(contribution.scale, 0.3)
105+
recipe.add_variable(contribution.scale, 0.3)
106106

107107
# Now we can configure the structural parameters. We tag the different
108108
# structural variables so we can easily turn them on and off in the
109109
# subsequent refinement.
110110
phase_cds = generator_cds.phase
111111
for par in phase_cds.sgpars.latpars:
112-
recipe.addVar(par, name=par.name + "_cds", tag="lat")
112+
recipe.add_variable(par, name=par.name + "_cds", tag="lat")
113113
for par in phase_cds.sgpars.adppars:
114-
recipe.addVar(par, 1, name=par.name + "_cds", tag="adp")
115-
recipe.addVar(phase_cds.sgpars.xyzpars.z_1, name="z_1_cds", tag="xyz")
114+
recipe.add_variable(par, 1, name=par.name + "_cds", tag="adp")
115+
recipe.add_variable(
116+
phase_cds.sgpars.xyzpars.z_1, name="z_1_cds", tag="xyz"
117+
)
116118
# Since we know these have stacking disorder, constrain the B33 adps for
117119
# each atom type.
118120
recipe.constrain("B33_1_cds", "B33_0_cds")
119-
recipe.addVar(generator_cds.delta2, name="delta2_cds", value=5)
121+
recipe.add_variable(generator_cds.delta2, name="delta2_cds", value=5)
120122

121123
phase_zns = generator_zns.phase
122124
for par in phase_zns.sgpars.latpars:
123-
recipe.addVar(par, name=par.name + "_zns", tag="lat")
125+
recipe.add_variable(par, name=par.name + "_zns", tag="lat")
124126
for par in phase_zns.sgpars.adppars:
125-
recipe.addVar(par, 1, name=par.name + "_zns", tag="adp")
126-
recipe.addVar(phase_zns.sgpars.xyzpars.z_1, name="z_1_zns", tag="xyz")
127+
recipe.add_variable(par, 1, name=par.name + "_zns", tag="adp")
128+
recipe.add_variable(
129+
phase_zns.sgpars.xyzpars.z_1, name="z_1_zns", tag="xyz"
130+
)
127131
recipe.constrain("B33_1_zns", "B33_0_zns")
128-
recipe.addVar(generator_zns.delta2, name="delta2_zns", value=2.5)
132+
recipe.add_variable(generator_zns.delta2, name="delta2_zns", value=2.5)
129133

130134
# Give the recipe away so it can be used!
131135
return recipe

docs/examples/crystalpdf.py

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -113,17 +113,17 @@ def makeRecipe(ciffile, datname):
113113
# the xyzpars, latpars, and adppars members of the SpaceGroupParameters
114114
# object.
115115
for par in sgpars.latpars:
116-
recipe.addVar(par)
116+
recipe.add_variable(par)
117117
for par in sgpars.adppars:
118-
recipe.addVar(par, 0.005)
118+
recipe.add_variable(par, 0.005)
119119

120120
# We now select non-structural parameters to refine.
121121
# This controls the scaling of the PDF.
122-
recipe.addVar(generator.scale, 1)
122+
recipe.add_variable(generator.scale, 1)
123123
# This is a peak-damping resolution term.
124-
recipe.addVar(generator.qdamp, 0.01)
124+
recipe.add_variable(generator.qdamp, 0.01)
125125
# This is a vibrational correlation term that sharpens peaks at low-r.
126-
recipe.addVar(generator.delta2, 5)
126+
recipe.add_variable(generator.delta2, 5)
127127

128128
# Give the recipe away so it can be used!
129129
return recipe

docs/examples/crystalpdfall.py

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -111,24 +111,24 @@ def makeRecipe(
111111

112112
# Now we vary and constrain Parameters as before.
113113
for par in phase_ni.sgpars:
114-
recipe.addVar(par, name=par.name + "_ni")
115-
delta2_ni = recipe.newVar("delta2_ni", 2.5)
114+
recipe.add_variable(par, name=par.name + "_ni")
115+
delta2_ni = recipe.create_new_variable("delta2_ni", 2.5)
116116
recipe.constrain(xgenerator_ni.delta2, delta2_ni)
117117
recipe.constrain(ngenerator_ni.delta2, delta2_ni)
118118
recipe.constrain(xgenerator_sini_ni.delta2, delta2_ni)
119119

120120
for par in phase_si.sgpars:
121-
recipe.addVar(par, name=par.name + "_si")
122-
delta2_si = recipe.newVar("delta2_si", 2.5)
121+
recipe.add_variable(par, name=par.name + "_si")
122+
delta2_si = recipe.create_new_variable("delta2_si", 2.5)
123123
recipe.constrain(xgenerator_si.delta2, delta2_si)
124124
recipe.constrain(xgenerator_sini_si.delta2, delta2_si)
125125

126126
# Now the experimental parameters
127-
recipe.addVar(xgenerator_ni.scale, name="xscale_ni")
128-
recipe.addVar(xgenerator_si.scale, name="xscale_si")
129-
recipe.addVar(ngenerator_ni.scale, name="nscale_ni")
130-
recipe.addVar(xcontribution_sini.scale, 1.0, "xscale_sini")
131-
recipe.newVar("pscale_sini_ni", 0.8)
127+
recipe.add_variable(xgenerator_ni.scale, name="xscale_ni")
128+
recipe.add_variable(xgenerator_si.scale, name="xscale_si")
129+
recipe.add_variable(ngenerator_ni.scale, name="nscale_ni")
130+
recipe.add_variable(xcontribution_sini.scale, 1.0, "xscale_sini")
131+
recipe.create_new_variable("pscale_sini_ni", 0.8)
132132
recipe.constrain(xgenerator_sini_ni.scale, "pscale_sini_ni")
133133
recipe.constrain(xgenerator_sini_si.scale, "1 - pscale_sini_ni")
134134

docs/examples/crystalpdfobjcryst.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -90,18 +90,18 @@ def makeRecipe(ciffile, datname):
9090
# As before, we have one free lattice parameter ('a'). We can simplify
9191
# things by iterating through all the sgpars.
9292
for par in phase.sgpars:
93-
recipe.addVar(par)
93+
recipe.add_variable(par)
9494
# set the initial thermal factor to a non-zero value
9595
assert hasattr(recipe, "B11_0")
9696
recipe.B11_0 = 0.1
9797

9898
# We now select non-structural parameters to refine.
9999
# This controls the scaling of the PDF.
100-
recipe.addVar(generator.scale, 1)
100+
recipe.add_variable(generator.scale, 1)
101101
# This is a peak-damping resolution term.
102-
recipe.addVar(generator.qdamp, 0.01)
102+
recipe.add_variable(generator.qdamp, 0.01)
103103
# This is a vibrational correlation term that sharpens peaks at low-r.
104-
recipe.addVar(generator.delta2, 5)
104+
recipe.add_variable(generator.delta2, 5)
105105

106106
# Give the recipe away so it can be used!
107107
return recipe

docs/examples/crystalpdftwodata.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -114,21 +114,21 @@ def makeRecipe(ciffile, xdatname, ndatname):
114114
recipe.add_contribution(ncontribution)
115115

116116
# Now we vary and constrain Parameters as before.
117-
recipe.addVar(xgenerator.scale, 1, "xscale")
118-
recipe.addVar(ngenerator.scale, 1, "nscale")
119-
recipe.addVar(xgenerator.qdamp, 0.01, "xqdamp")
120-
recipe.addVar(ngenerator.qdamp, 0.01, "nqdamp")
117+
recipe.add_variable(xgenerator.scale, 1, "xscale")
118+
recipe.add_variable(ngenerator.scale, 1, "nscale")
119+
recipe.add_variable(xgenerator.qdamp, 0.01, "xqdamp")
120+
recipe.add_variable(ngenerator.qdamp, 0.01, "nqdamp")
121121
# delta2 is a non-structual material property. Thus, we constrain together
122122
# delta2 Parameter from each PDFGenerator.
123-
delta2 = recipe.newVar("delta2", 2)
123+
delta2 = recipe.create_new_variable("delta2", 2)
124124
recipe.constrain(xgenerator.delta2, delta2)
125125
recipe.constrain(ngenerator.delta2, delta2)
126126

127127
# We only need to constrain phase properties once since there is a single
128128
# ObjCrystCrystalParSet for the Crystal.
129129
phase = xgenerator.phase
130130
for par in phase.sgpars:
131-
recipe.addVar(par)
131+
recipe.add_variable(par)
132132
recipe.B11_0 = 0.1
133133

134134
# Give the recipe away so it can be used!

docs/examples/crystalpdftwophase.py

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -89,16 +89,16 @@ def makeRecipe(niciffile, siciffile, datname):
8989
# Configure the fit variables
9090
# Start by configuring the scale factor and resolution factors.
9191
# We want the sum of the phase scale factors to be 1.
92-
recipe.newVar("scale_ni", 0.1)
92+
recipe.create_new_variable("scale_ni", 0.1)
9393
recipe.constrain(generator_ni.scale, "scale_ni")
9494
recipe.constrain(generator_si.scale, "1 - scale_ni")
9595
# We also want the resolution factor to be the same on each.
96-
recipe.newVar("qdamp", 0.03)
96+
recipe.create_new_variable("qdamp", 0.03)
9797
recipe.constrain(generator_ni.qdamp, "qdamp")
9898
recipe.constrain(generator_si.qdamp, "qdamp")
9999

100100
# Vary the global scale as well.
101-
recipe.addVar(contribution.scale, 1)
101+
recipe.add_variable(contribution.scale, 1)
102102

103103
# Now we can configure the structural parameters. Since we're using
104104
# ObjCrystCrystalParSets, the space group constraints are automatically
@@ -107,13 +107,13 @@ def makeRecipe(niciffile, siciffile, datname):
107107
# First the nickel parameters
108108
phase_ni = generator_ni.phase
109109
for par in phase_ni.sgpars:
110-
recipe.addVar(par, name=par.name + "_ni")
111-
recipe.addVar(generator_ni.delta2, name="delta2_ni")
110+
recipe.add_variable(par, name=par.name + "_ni")
111+
recipe.add_variable(generator_ni.delta2, name="delta2_ni")
112112
# Next the silicon parameters
113113
phase_si = generator_si.phase
114114
for par in phase_si.sgpars:
115-
recipe.addVar(par, name=par.name + "_si")
116-
recipe.addVar(generator_si.delta2, name="delta2_si")
115+
recipe.add_variable(par, name=par.name + "_si")
116+
recipe.add_variable(generator_si.delta2, name="delta2_si")
117117

118118
# We have prior information from the earlier examples so we'll use it here
119119
# in the form of restraints.

docs/examples/debyemodel.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -139,9 +139,9 @@ def makeRecipe():
139139
# Specify which Parameters we want to refine.
140140

141141
# Vary the offset
142-
recipe.addVar(contribution.offset, 0)
142+
recipe.add_variable(contribution.offset, 0)
143143
# We also vary the Debye temperature.
144-
recipe.addVar(contribution.thetaD, 100)
144+
recipe.add_variable(contribution.thetaD, 100)
145145

146146
# We would like to 'suggest' that the offset should remain positive. This
147147
# is somethine that we know about the system that might help the refinement

docs/examples/debyemodelII.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -83,11 +83,11 @@ def makeRecipeII():
8383
# Vary the offset from each FitContribution separately, while keeping the
8484
# Debye temperatures the same. We give each offset variable a different
8585
# name in the recipe so it retains its identity.
86-
recipe.addVar(recipe.lowT.offset, name="lowToffset")
87-
recipe.addVar(recipe.highT.offset, name="highToffset")
86+
recipe.add_variable(recipe.lowT.offset, name="lowToffset")
87+
recipe.add_variable(recipe.highT.offset, name="highToffset")
8888
# We create a new Variable and use the recipe's "constrain" method to
8989
# associate the Debye temperature parameters with that variable.
90-
recipe.newVar("thetaD", 100)
90+
recipe.create_new_variable("thetaD", 100)
9191
recipe.constrain(recipe.lowT.thetaD, "thetaD")
9292
recipe.constrain(recipe.highT.thetaD, "thetaD")
9393
return recipe

docs/examples/ellipsoidsas.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -78,10 +78,10 @@ def makeRecipe(datname):
7878
# SASGenerator these are named like "radius_width".
7979
#
8080
# We want to fit the scale factor, radii and background factors.
81-
recipe.addVar(generator.scale, 1)
82-
recipe.addVar(generator.radius_a, 50)
83-
recipe.addVar(generator.radius_b, 500)
84-
recipe.addVar(generator.background, 0)
81+
recipe.add_variable(generator.scale, 1)
82+
recipe.add_variable(generator.radius_a, 50)
83+
recipe.add_variable(generator.radius_b, 500)
84+
recipe.add_variable(generator.background, 0)
8585

8686
# Give the recipe away so it can be used!
8787
return recipe

docs/examples/gaussiangenerator.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,9 +161,9 @@ def makeRecipe():
161161
# that the Parameters belong to the GaussianGenerator, not the
162162
# FitContribution as in gaussianrecipe.py. We initialize parameters as in
163163
# gaussianrecipe.py so we can expect the same output.
164-
recipe.addVar(generator.A, 1)
165-
recipe.addVar(generator.x0, 5)
166-
recipe.addVar(generator.sigma, name="sig")
164+
recipe.add_variable(generator.A, 1)
165+
recipe.add_variable(generator.x0, 5)
166+
recipe.add_variable(generator.sigma, name="sig")
167167
recipe.sig.value = 1
168168

169169
# Give the recipe away so it can be used!

0 commit comments

Comments
 (0)