9999 base , "newVar" , "create_new_variable" , removal_version
100100)
101101
102+ isFree_dep_msg = build_deprecation_message (
103+ base , "isFree" , "is_free" , removal_version
104+ )
105+
106+ getValues_dep_msg = build_deprecation_message (
107+ base , "getValues" , "get_values" , removal_version
108+ )
109+
110+ getNames_dep_msg = build_deprecation_message (
111+ base , "getNames" , "get_names" , removal_version
112+ )
113+
114+ getBounds_dep_msg = build_deprecation_message (
115+ base , "getBounds" , "get_bounds_pairs" , removal_version
116+ )
117+
118+ getBounds2_dep_msg = build_deprecation_message (
119+ base , "getBounds2" , "get_bounds_array" , removal_version
120+ )
121+
122+ boundsToRestraints_dep_msg = build_deprecation_message (
123+ base , "boundsToRestraints" , "convert_bounds_to_restraints" , removal_version
124+ )
125+
102126
103127class FitRecipe (_fitrecipe_interface , RecipeOrganizer ):
104128 """FitRecipe class.
@@ -152,24 +176,24 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer):
152176 Properties
153177 ----------
154178 names
155- Variable names (read only). See getNames .
179+ Variable names (read only). See get_names .
156180 values
157- Variable values (read only). See getValues .
181+ Variable values (read only). See get_values .
158182 fixednames
159183 Names of the fixed refinable variables (read only).
160184 fixedvalues
161185 Values of the fixed refinable variables (read only).
162186 bounds
163- Bounds on parameters (read only). See getBounds .
187+ Bounds on parameters (read only). See get_bounds_pairs .
164188 bounds2
165- Bounds on parameters (read only). See getBounds2 .
189+ Bounds on parameters (read only). See get_bounds_array .
166190 """
167191
168192 fixednames = property (
169193 lambda self : [
170194 v .name
171195 for v in self ._parameters .values ()
172- if not (self .isFree (v ) or self .isConstrained (v ))
196+ if not (self .is_free (v ) or self .isConstrained (v ))
173197 ],
174198 doc = "names of the fixed refinable variables" ,
175199 )
@@ -178,13 +202,13 @@ class FitRecipe(_fitrecipe_interface, RecipeOrganizer):
178202 [
179203 v .value
180204 for v in self ._parameters .values ()
181- if not (self .isFree (v ) or self .isConstrained (v ))
205+ if not (self .is_free (v ) or self .isConstrained (v ))
182206 ]
183207 ),
184208 doc = "values of the fixed refinable variables" ,
185209 )
186- bounds = property (lambda self : self .getBounds ())
187- bounds2 = property (lambda self : self .getBounds2 ())
210+ bounds = property (lambda self : self .get_bounds_pairs ())
211+ bounds2 = property (lambda self : self .get_bounds_array ())
188212
189213 def __init__ (self , name = "fit" ):
190214 """Initialization."""
@@ -935,10 +959,19 @@ def free(self, *args, **kw):
935959
936960 return
937961
938- def isFree (self , var ):
962+ def is_free (self , var ):
939963 """Check if a variable is fixed."""
940964 return not self ._tagmanager .hasTags (var , self ._fixedtag )
941965
966+ @deprecated (isFree_dep_msg )
967+ def isFree (self , var ):
968+ """This function has been deprecated and will be removed in version
969+ 4.0.0.
970+
971+ Please use diffpy.srfit.fitbase.FitRecipe.is_free instead.
972+ """
973+ return self .is_free (var )
974+
942975 def unconstrain (self , * pars ):
943976 """Unconstrain a Parameter.
944977
@@ -1034,33 +1067,78 @@ def constrain(self, par, con, ns={}):
10341067 RecipeOrganizer .constrain (self , par , con , ns )
10351068 return
10361069
1037- def getValues (self ):
1070+ def get_values (self ):
10381071 """Get the current values of the variables in a list."""
10391072 return array (
1040- [v .value for v in self ._parameters .values () if self .isFree (v )]
1073+ [v .value for v in self ._parameters .values () if self .is_free (v )]
10411074 )
10421075
1043- def getNames (self ):
1076+ @deprecated (getValues_dep_msg )
1077+ def getValues (self ):
1078+ """This function has been deprecated and will be removed in version
1079+ 4.0.0.
1080+
1081+ Please use diffpy.srfit.fitbase.FitRecipe.get_values instead."""
1082+ return self .get_values ()
1083+
1084+ def get_names (self ):
10441085 """Get the names of the variables in a list."""
1045- return [v .name for v in self ._parameters .values () if self .isFree (v )]
1086+ return [v .name for v in self ._parameters .values () if self .is_free (v )]
10461087
1047- def getBounds (self ):
1088+ @deprecated (getNames_dep_msg )
1089+ def getNames (self ):
1090+ """This function has been deprecated and will be removed in version
1091+ 4.0.0.
1092+
1093+ Please use diffpy.srfit.fitbase.FitRecipe.get_names instead."""
1094+ return self .get_names ()
1095+
1096+ def get_bounds_pairs (self ):
10481097 """Get the bounds on variables in a list.
10491098
1050- Returns a list of (lb, ub) pairs, where lb is the lower bound
1051- and ub is the upper bound.
1099+ Returns
1100+ -------
1101+ bounds_pair_list : list of tuple of float
1102+ A list of ``(lower, upper)`` bounds on the variables, in the same
1103+ order as ``get_names`` and ``get_values``.
10521104 """
1053- return [v .bounds for v in self ._parameters .values () if self .isFree (v )]
1105+ return [v .bounds for v in self ._parameters .values () if self .is_free (v )]
1106+
1107+ @deprecated (getBounds_dep_msg )
1108+ def getBounds (self ):
1109+ """This function has been deprecated and will be removed in version
1110+ 4.0.0.
10541111
1112+ Please use diffpy.srfit.fitbase.FitRecipe.get_bounds_pairs
1113+ instead.
1114+ """
1115+ return self .get_bounds_pairs ()
1116+
1117+ def get_bounds_array (self ):
1118+ """Get the bounds on variables in two numpy arrays.
1119+
1120+ Returns
1121+ -------
1122+ lower_bounds : numpy.ndarray
1123+ A numpy array of lower bounds on the variables, in the same order
1124+ as ``get_names`` and ``get_values``.
1125+ upper_bounds : numpy.ndarray
1126+ A numpy array of upper bounds on the variables, in the same order
1127+ as ``get_names`` and ``get_values``.
1128+ """
1129+ bounds = self .get_bounds_pairs ()
1130+ lower_bounds = array ([b [0 ] for b in bounds ])
1131+ upper_bounds = array ([b [1 ] for b in bounds ])
1132+ return lower_bounds , upper_bounds
1133+
1134+ @deprecated (getBounds2_dep_msg )
10551135 def getBounds2 (self ):
1056- """Get the bounds on variables in two lists.
1136+ """This function has been deprecated and will be removed in version
1137+ 4.0.0.
10571138
1058- Returns lower- and upper-bound lists of variable bounds .
1139+ Please use diffpy.srfit.fitbase.FitRecipe.get_bounds_array instead .
10591140 """
1060- bounds = self .getBounds ()
1061- lb = array ([b [0 ] for b in bounds ])
1062- ub = array ([b [1 ] for b in bounds ])
1063- return lb , ub
1141+ return self .get_bounds_array ()
10641142
10651143 def set_plot_defaults (self , ** kwargs ):
10661144 """Set default plotting options for all future plots.
@@ -1346,18 +1424,23 @@ def plot_recipe(self, ax=None, return_fig=False, **kwargs):
13461424 else :
13471425 return figures , axes_list
13481426
1349- def boundsToRestraints (self , sig = 1 , scaled = False ):
1427+ def convert_bounds_to_restraints (self , sig = 1 , scaled = False ):
13501428 """Turn all bounded parameters into restraints.
13511429
13521430 The bounds become limits on the restraint.
13531431
1354- Attributes
1432+ Parameters
13551433 ----------
1356- sig
1357- The uncertainty on the bounds (scalar or iterable,
1358- default 1).
1359- scaled
1360- Scale the restraints, see restrain.
1434+ sig : float or iterable of float, optional
1435+ The number of standard deviations associated with each bound.
1436+ Smaller values produce stronger restraints. If a scalar is given,
1437+ the same value is applied to all parameters. If an iterable is
1438+ provided, it must match the number of parameters. Default is 1.
1439+
1440+ scaled : bool, optional
1441+ If True, scale each restraint by the magnitude of the corresponding
1442+ parameter, consistent with the behavior of :meth:`restrain`.
1443+ Default is False.
13611444 """
13621445 pars = self ._parameters .values ()
13631446 if not hasattr (sig , "__iter__" ):
@@ -1368,11 +1451,22 @@ def boundsToRestraints(self, sig=1, scaled=False):
13681451 )
13691452 return
13701453
1454+ @deprecated (boundsToRestraints_dep_msg )
1455+ def boundsToRestraints (self , sig = 1 , scaled = False ):
1456+ """This function has been deprecated and will be removed in version
1457+ 4.0.0.
1458+
1459+ Please use diffpy.srfit.fitbase.FitRecipe.convert_bounds_to_restraints
1460+ instead.
1461+ """
1462+ self .convert_bounds_to_restraints (sig , scaled )
1463+ return
1464+
13711465 def _apply_values (self , p ):
13721466 """Apply variable values to the variables."""
13731467 if len (p ) == 0 :
13741468 return
1375- vargen = (v for v in self ._parameters .values () if self .isFree (v ))
1469+ vargen = (v for v in self ._parameters .values () if self .is_free (v ))
13761470 for var , pval in zip (vargen , p ):
13771471 var .setValue (pval )
13781472 return
0 commit comments