From 7a6dafbec75388be1157fc25fc1ca091afe66a39 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 19 Aug 2024 17:06:34 +0800 Subject: [PATCH 1/3] change peakextraction function to numpydoc --- src/diffpy/srmise/peakextraction.py | 79 +++++++++++++++++++---------- 1 file changed, 52 insertions(+), 27 deletions(-) diff --git a/src/diffpy/srmise/peakextraction.py b/src/diffpy/srmise/peakextraction.py index c62102b..2710ea2 100644 --- a/src/diffpy/srmise/peakextraction.py +++ b/src/diffpy/srmise/peakextraction.py @@ -33,29 +33,44 @@ class PeakExtraction(object): """Class for peak extraction. - Data members - x: x coordinates of the data - y: y coordinates of the data - dx: uncertainties in the x coordinates (not used) - dy: uncertainties in the y coordinates - effective_dy: uncertainties in the y coordinates actually used during extraction - rng: [xmin, xmax] Range of x coordinates over which to extract peaks - pf: Sequence of peak functions that can be extracted - initial_peaks: Peaks present at start of extraction - baseline: Baseline for data - cres: Resolution of clustering - error_method: ErrorEvaluator class used to compare models + Parameters + ---------- + x : array-like + The x coordinates of the data + y : array-like + The y coordinates of the data + dx : array-like + The uncertainties in the x coordinates (not used) + dy : array-like + The uncertainties in the y coordinates + effective_dy : array-like + The uncertainties in the y coordinates actually used during extraction + rng : list + The [xmin, xmax] Range of x coordinates over which to extract peaks + pf : array-like + The sequence of peak functions that can be extracted + initial_peaks: Peaks object + The peaks present at start of extraction + baseline : Baseline object + The baseline for data + cres : float + The resolution of clustering + error_method : ErrorEvaluator class + The Evaluation class used to compare models Calculated members - extracted: ModelCluster after extraction - extraction_type: Type of extraction + ------------------ + extracted : ModelCluster object + The ModelCluster object after extraction + extraction_type : Type of extraction """ def __init__(self, newvars=[]): """Initialize PeakExtraction object. Parameters - newvars: Sequence of strings that represent additional extraction parameters.""" + newvars : array-like + Sequence of strings that represent additional extraction parameters.""" self.clear() self.extractvars = dict.fromkeys( ( @@ -77,7 +92,9 @@ def __init__(self, newvars=[]): return def clear(self): - """Clear all members.""" + """Clear all members. + + The purpose of the method is to ensure the object is in initialized state.""" self.x = None self.y = None self.dx = None @@ -119,17 +136,24 @@ def setdata(self, x, y, dx=None, dy=None): def setvars(self, quiet=False, **kwds): """Set one or more extraction variables. - Variables - quiet: [False] Log changes quietly. - - Keywords - cres: The clustering resolution, must be > 0. - effective_dy: The uncertainties actually used during extraction - pf: Sequence of PeakFunctionBase subclass instances. - baseline: Baseline instance or BaselineFunction instance (use built-in estimation) - error_method: ErrorEvaluator subclass instance used to compare models (default AIC) - initial_peaks: Peaks instance. These peaks are present at the start of extraction. - rng: Sequence specifying the least and greatest x-values over which to extract peaks. + Parameters + ---------- + quiet : bool + The log changes quietly. Default is False. + cres : float + The clustering resolution, must be > 0. + effective_dy : array-like + The uncertainties actually used during extraction + pf : list + The sequence of PeakFunctionBase subclass instances. + baseline : Baseline instance or BaselineFunction instance + The Baseline instance or BaselineFunction instance that use built-in estimation + error_method : ErrorEvaluator subclass instance + The ErrorEvaluator subclass instance used to compare models. Default is AIC. + initial_peaks : Peaks instance + These peaks are present at the start of extraction. + rng : array-like + The sequence specifying the least and greatest x-values over which to extract peaks. """ for k, v in kwds.items(): if k in self.extractvars: @@ -1309,6 +1333,7 @@ def fit_single(self): from diffpy.srmise.modelevaluators.aicc import AICc from diffpy.srmise.peaks.gaussianoverr import GaussianOverR + from diffpy.srmise.dataclusters import DataClusters srmiselog.setlevel("info") srmiselog.liveplotting(False) From 40aae2b09574b04b4413e3380cf0b3f5fc84dc52 Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 19 Aug 2024 17:07:28 +0800 Subject: [PATCH 2/3] pre-commit run --- src/diffpy/srmise/peakextraction.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/diffpy/srmise/peakextraction.py b/src/diffpy/srmise/peakextraction.py index 2710ea2..817c29d 100644 --- a/src/diffpy/srmise/peakextraction.py +++ b/src/diffpy/srmise/peakextraction.py @@ -1331,9 +1331,9 @@ def fit_single(self): from numpy.random import randn + from diffpy.srmise.dataclusters import DataClusters from diffpy.srmise.modelevaluators.aicc import AICc from diffpy.srmise.peaks.gaussianoverr import GaussianOverR - from diffpy.srmise.dataclusters import DataClusters srmiselog.setlevel("info") srmiselog.liveplotting(False) From 99124a0c0e8577afe45b2c258539cd3e61488b4e Mon Sep 17 00:00:00 2001 From: stevenhua0320 Date: Mon, 19 Aug 2024 17:18:48 +0800 Subject: [PATCH 3/3] remove unused import --- src/diffpy/srmise/peakextraction.py | 1 - 1 file changed, 1 deletion(-) diff --git a/src/diffpy/srmise/peakextraction.py b/src/diffpy/srmise/peakextraction.py index 817c29d..8d019b0 100644 --- a/src/diffpy/srmise/peakextraction.py +++ b/src/diffpy/srmise/peakextraction.py @@ -1331,7 +1331,6 @@ def fit_single(self): from numpy.random import randn - from diffpy.srmise.dataclusters import DataClusters from diffpy.srmise.modelevaluators.aicc import AICc from diffpy.srmise.peaks.gaussianoverr import GaussianOverR