@@ -171,24 +171,27 @@ def defaultvars(self, *args):
171171 """Set unset(=None) extraction variables to default values.
172172
173173 Certain variables may be partially set for convenience, and are transformed
174- appropriately. See 'Default values' below.
174+ appropriately. See 'Default values assigned ' below.
175175
176176 Parameters
177- Any number of strings corresponding to extraction variables. These
178- variables are reset to their default values even if another value
179- already exists.
180-
181- Default values:
182- cres -> 4 times the average spacing between elements in x
183- effective_dy -> The data dy if all elements > 0, otherwise 5% of max(y)-min(y).
184- If effective_dy is a positive scalar, then an array of that
185- value of appropriate length.
186- pf -> [GaussianOverR(maxwidth=x[-1]-x[0])]
187- baseline -> Flat baseline located at y=0.
188- error_method -> AIC (Aikake Information Criterion)
189- initial_peaks -> No initial peaks
190- rng -> [x[0], x[-1]]. Partially set ranges like [None, 100.] replace None with
191- the appropriate limit in the data.
177+ ----------
178+ *args : str
179+ The variable argument list where each string corresponds to an extraction
180+ variable name.
181+
182+ Default values assigned:
183+ - `cres` : 4 times the average spacing between elements in `x`.
184+ - `effective_dy` : If all elements in `y` are positive, it's set to the data `dy`;
185+ otherwise, it's 5% of the range (`max(y)` - `min(y)`). If `effective_dy`
186+ is a positive scalar, an array of that value with a length matching `y` is used.
187+ - `pf` : A list containing a single Gaussian overlap function with the maximum width
188+ spanning the entire `x` range (`x[-1] - x[0]`).
189+ - `baseline` : A flat baseline at `y=0`, indicating no background signal.
190+ - `error_method` : Uses the AIC (Akaike Information Criterion) for evaluating model fits.
191+ - `initial_peaks` : Assumes no initial peak guesses, implying peaks will be detected from scratch.
192+ - `rng` : The default range is set to span the entire `x` dataset, i.e., `[x[0], x[-1]]`.
193+ If a range is partially defined, e.g., `[None, 100.]`, the `None` value is replaced
194+ with the respective boundary of the `x` data.
192195
193196 Note that the default values of very important parameters like the uncertainty
194197 and clustering resolution are crude guesses at best.
@@ -264,7 +267,13 @@ def plot(self, **kwds):
264267
265268 Uses initial peaks instead if no peaks have been extracted.
266269
267- Takes same keywords as ModelCluster.plottable()"""
270+ Takes same keywords as ModelCluster.plottable()
271+
272+ Parameters
273+ ----------
274+ **kwds :args
275+ The keyword arguments to pass to matplotlib.
276+ """
268277 plt .clf ()
269278 if self .extracted is not None :
270279 plt .plot (* self .extracted .plottable (kwds ))
@@ -292,9 +301,14 @@ def plot(self, **kwds):
292301 def read (self , filename ):
293302 """load PeakExtraction object from file
294303
295- filename -- file from which to read
304+ Parameters
305+ ----------
306+ filename : str
307+ The file from which to read
296308
297- returns self
309+ Returns
310+ -------
311+ self
298312 """
299313 try :
300314 self .readstr (open (filename , "rb" ).read ())
@@ -312,7 +326,10 @@ def readstr(self, datastring):
312326 """Initialize members from string.
313327
314328 Parameters
315- datastring: The raw data to read"""
329+ ----------
330+ datastring : array-like
331+ The raw data to read
332+ """
316333 from diffpy .srmise .basefunction import BaseFunction
317334
318335 self .clear ()
@@ -525,15 +542,23 @@ def write(self, filename):
525542 """Write string representation of PeakExtraction instance to file.
526543
527544 Parameters
528- filename: the name of the file to write"""
545+ ----------
546+ filename : str
547+ The name of the file to write
548+ """
529549 bytes = self .writestr ()
530550 f = open (filename , "w" )
531551 f .write (bytes )
532552 f .close ()
533553 return
534554
535555 def writestr (self ):
536- """Return string representation of PeakExtraction object."""
556+ """Return string representation of PeakExtraction object.
557+
558+ Returns
559+ -------
560+ The str representation of PeakExtraction object
561+ """
537562 import time
538563 from getpass import getuser
539564
@@ -702,11 +727,16 @@ def estimate_peak(self, x, add=True):
702727 Peaks already extracted, if any, are taken into account. If none exist,
703728 use those specified by initial_peaks instead.
704729
705- Parameters:
706- x: Coordinate of the point of interest
707- add: (True) Automatically add peak to extracted peaks or initial_peaks.
708-
709- Return a Peak object, or None if estimation fails.
730+ Parameters
731+ ----------
732+ x : array-like
733+ The oordinate of the point of interest
734+ add : bool
735+ Automatically add peak to extracted peaks or initial_peaks. Default is True.
736+
737+ Returns
738+ -------
739+ The Peak object, or None if estimation fails.
710740 """
711741 # Make sure all required extraction variables have some value
712742 self .defaultvars ()
@@ -758,7 +788,10 @@ def add_peaks(self, peaks):
758788 """Add peaks to extracted peaks, or initial_peaks if no extracted peaks exist.
759789
760790 Parameters
761- peaks: A Peaks instance"""
791+ ----------
792+ peaks: Peaks object
793+ The peaks instance
794+ """
762795 if self .extracted is not None :
763796 self .extracted .replacepeaks (peaks )
764797 else :
0 commit comments