@@ -887,11 +887,27 @@ def replacepeaks(self, newpeaks, delslice=slice(0, 0)):
887
887
return
888
888
889
889
def deletepeak (self , idx ):
890
- """Delete the peak at the given index."""
890
+ """Delete the peak at the given index.
891
+
892
+ Parameters
893
+ ----------
894
+ idx : int
895
+ Index of peak to delete.
896
+
897
+ Returns
898
+ -------
899
+ None
900
+ """
891
901
self .replacepeaks ([], slice (idx , idx + 1 ))
892
902
893
903
def estimatepeak (self ):
894
- """Attempt to add single peak to empty cluster. Return True if successful."""
904
+ """Attempt to add single peak to empty cluster. Return True if successful.
905
+
906
+ Returns
907
+ -------
908
+ bool
909
+ True if successful, False otherwise.
910
+ """
895
911
# STUB!!! ###
896
912
# Currently only a single peak function is supported. Dynamic
897
913
# selection from multiple types may require additional support
@@ -926,16 +942,26 @@ def fit(
926
942
"""Perform a chi-square fit of the model to data in cluster.
927
943
928
944
Parameters
929
- justify - Revert to initial model (if one exists) if new model
930
- has only a single peak and the quality of the fit suggests
931
- additional peaks are present.
932
- ntrials - The maximum number of function evaluations.
933
- '0' indicates the fitting algorithm's default.
934
- fitbaseline - Whether to fit baseline along with peaks
935
- estimate - Estimate a single peak from data if model is empty.
936
- cov - Optional ModelCovariance object preserves covariance information.
937
- cov_format - Parameterization to use in cov.
945
+ ----------
946
+ justify : bool
947
+ Revert to initial model (if one exists) if new model
948
+ has only a single peak and the quality of the fit suggests
949
+ additional peaks are present. Default is False.
950
+ ntrials : int
951
+ The maximum number of function evaluations.
952
+ '0' indicates the fitting algorithm's default.
953
+ fitbaseline : bool
954
+ Whether to fit baseline along with peaks. Default is False.
955
+ estimate : bool
956
+ Estimate a single peak from data if model is empty. Default is True.
957
+ cov : ModelCovariance or None
958
+ Optional ModelCovariance object preserves covariance information.
959
+ cov_format : str
960
+ Parameterization to use in cov.
938
961
962
+ Returns
963
+ -------
964
+ ModelEvaluator or None
939
965
If fitting changes a model, return ModelEvaluator instance. Otherwise
940
966
return None.
941
967
"""
@@ -1040,10 +1066,16 @@ def contingent_fit(self, minpoints, growth_threshold):
1040
1066
"""Fit cluster if it has grown sufficiently large since its last fit.
1041
1067
1042
1068
Parameters
1043
- minpoints - The minimum number of points an empty cluster requires to fit.
1044
- growth_threshold - Fit non-empty model if (currentsize/oldsize) >= this value.
1069
+ ----------
1070
+ minpoints : int
1071
+ The minimum number of points an empty cluster requires to fit.
1072
+ growth_threshold : float
1073
+ Fit non-empty model if (currentsize/oldsize) >= this value.
1045
1074
1046
- Return ModelEvaluator instance if fit changed, otherwise None.
1075
+ Returns
1076
+ -------
1077
+ ModelEvaluator or None
1078
+ Return ModelEvaluator instance if fit changed, otherwise None.
1047
1079
"""
1048
1080
if self .never_fit :
1049
1081
return None
@@ -1115,10 +1147,16 @@ def reduce_to(self, x, y):
1115
1147
a maximum very close to x may prevent optimal results.
1116
1148
1117
1149
Parameters
1118
- x - Position at which to match
1119
- y - Height to match.
1150
+ ----------
1151
+ x : array-like
1152
+ The position at which to match
1153
+ y : array-like
1154
+ The height to match.
1120
1155
1121
- Return ModelEvaluator instance if fit changed, otherwise None."""
1156
+ Returns
1157
+ -------
1158
+ ModelEvaluator or None
1159
+ Return ModelEvaluator instance if fit changed, otherwise None."""
1122
1160
# No reduction neccessary
1123
1161
if self .model .value (x ) < y :
1124
1162
logger .debug ("reduce_to: No reduction necessary." )
@@ -1142,7 +1180,19 @@ def reduce_to(self, x, y):
1142
1180
return quality
1143
1181
1144
1182
def value (self , r = None ):
1145
- """Return value of baseline+model over cluster."""
1183
+ """Return value of baseline+model over cluster.
1184
+
1185
+ Parameters
1186
+ ----------
1187
+ r : array-like, optional
1188
+ value(s) over which to calculate the baseline's value.
1189
+ The default is over the entire cluster.
1190
+
1191
+ Returns
1192
+ -------
1193
+ float
1194
+ The value of baseline+model over cluster.
1195
+ """
1146
1196
if len (self .model ) == 0 :
1147
1197
return self .valuebl (r )
1148
1198
else :
@@ -1157,8 +1207,14 @@ def valuebl(self, r=None):
1157
1207
If no baseline exists its value is 0 everywhere.
1158
1208
1159
1209
Parameters
1210
+ ----------
1160
1211
r - value(s) over which to calculate the baseline's value.
1161
1212
The default is over the entire cluster.
1213
+
1214
+ Returns
1215
+ -------
1216
+ float
1217
+ The value of baseline's value.
1162
1218
"""
1163
1219
if self .baseline is None :
1164
1220
if r is None :
@@ -1183,10 +1239,18 @@ def quality(self, evaluator=None, **kwds):
1183
1239
details see ModelEvaluator documentation.
1184
1240
1185
1241
Parameters
1186
- evaluator - A ModelEvaluator class (not instance) to use instead of default.
1242
+ ----------
1243
+ evaluator : ModelEvaluator class or None
1244
+ The ModelEvaluator class to use. Default is None.
1187
1245
1188
1246
Keywords
1247
+ --------
1189
1248
kwds - Keyword arguments passed the the ModelEvaluator's evaluate() method.
1249
+
1250
+ Returns
1251
+ -------
1252
+ ModelEvaluator instance
1253
+ The ModelEvaluator instance with quality calculated
1190
1254
"""
1191
1255
if evaluator is None :
1192
1256
evaluator_inst = self .error_method ()
@@ -1199,7 +1263,14 @@ def plottable(self, joined=False):
1199
1263
"""Return sequence suitable for plotting cluster model+baseline with matplotlib.
1200
1264
1201
1265
Parameters
1202
- joined - Return sum of all peaks, or each one individually.
1266
+ ----------
1267
+ joined : bool
1268
+ Return sum of all peaks if joined is True, or each one individually if False.
1269
+
1270
+ Returns
1271
+ -------
1272
+ array-like
1273
+ A sequence of plottable objects.
1203
1274
"""
1204
1275
if joined :
1205
1276
return [self .r_cluster , self .y_cluster , self .r_cluster , self .value ()]
@@ -1212,14 +1283,26 @@ def plottable(self, joined=False):
1212
1283
return toreturn
1213
1284
1214
1285
def plottable_residual (self ):
1215
- """Return sequence suitable for plotting cluster residual with matplotlib."""
1286
+ """Return sequence suitable for plotting cluster residual with matplotlib.
1287
+
1288
+ Returns
1289
+ -------
1290
+ array-like
1291
+ A sequence of plottable clusters and residuals.
1292
+ """
1216
1293
return [self .r_cluster , self .residual ()]
1217
1294
1218
1295
def augment (self , source ):
1219
1296
"""Add peaks from another ModelCluster that improve this one's quality.
1220
1297
1221
1298
Parameters
1222
- source - A ModelCluster instance
1299
+ ----------
1300
+ source : ModelCluster instance
1301
+ The ModelCluster instance to augment the model's quality.
1302
+
1303
+ Returns
1304
+ -------
1305
+ None
1223
1306
"""
1224
1307
best_model = self .model .copy ()
1225
1308
best_qual = self .quality ()
0 commit comments