@@ -30,21 +30,37 @@ class FromSequence(BaselineFunction):
30
30
interpolation domain. This baseline function permits no free parameters."""
31
31
32
32
def __init__ (self , * args , ** kwds ):
33
- """Initialize baseline corresponding to sequences x and y .
33
+ """Initialize a baseline object based on input sequences `x` and `y` .
34
34
35
- Usage:
36
- FromSequence(xlist, ylist) or
37
- FromSequence(x=xlist, y=ylist)
35
+ This class provides two ways to initialize: by directly providing the sequences or by
36
+ specifying a file that contains the sequences.
38
37
39
- FromSequence("filename") or
40
- FromSequence(file="filename")
38
+ Parameters
39
+ ----------
40
+ *args : tuple
41
+ The variable length argument list. Can be used to pass `x` and `y` sequences directly.
42
+
43
+ **kwds : dict
44
+ The arbitrary keyword arguments. Can be used to specify `x`, `y` sequences or a `file` name.
45
+
46
+ x : array_like, optional
47
+ The sequence of x-values defining the baseline. Can be passed as a positional argument or via keyword.
48
+
49
+ y : array_like, optional
50
+ The sequence of y-values defining the baseline. Must be provided alongside `x`.
41
51
52
+ file : str, optional
53
+ The name of the file containing two columns: one for x-values and one for y-values.
42
54
43
- Parameters/Keywords
44
- x: Sequence of x values defining baseline.
45
- y: Sequence of y values defining baseline.
46
- or
47
- file: Name of file with column of x values and column of y values.
55
+ Usage
56
+ -----
57
+ 1. Directly with sequences:
58
+ - `FromSequence(xlist, ylist)`
59
+ - `FromSequence(x=xlist, y=ylist)`
60
+
61
+ 2. From a file:
62
+ - `FromSequence("filename")`
63
+ - `FromSequence(file="filename")`
48
64
"""
49
65
if len (args ) == 1 and len (kwds ) == 0 :
50
66
# load from file
@@ -88,8 +104,17 @@ def estimate_parameters(self, r, y):
88
104
to estimate.
89
105
90
106
Parameters
91
- r: (Numpy array) Data along r from which to estimate, Ignored
92
- y: (Numpy array) Data along y from which to estimate, Ignored"""
107
+ ----------
108
+ r : array-like
109
+ The data along r from which to estimate, Ignored
110
+ y : array-like
111
+ The data along y from which to estimate, Ignored
112
+
113
+ Returns
114
+ -------
115
+ array-like
116
+ The empty numpy array
117
+ """
93
118
return np .array ([])
94
119
95
120
def _jacobianraw (self , pars , r , free ):
@@ -98,9 +123,19 @@ def _jacobianraw(self, pars, r, free):
98
123
A FromSequence baseline has no parameters.
99
124
100
125
Parameters
101
- pars: Empty sequence
102
- r: sequence or scalar over which pars is evaluated
103
- free: Empty sequence."""
126
+ ----------
127
+ pars :array-like
128
+ The empty sequence
129
+ r : array-like
130
+ The sequence or scalar over which pars is evaluated
131
+ free : array-like
132
+ The empty sequence.
133
+
134
+ Returns
135
+ -------
136
+ array-like
137
+ The empty numpy array
138
+ """
104
139
if len (pars ) != self .npars :
105
140
emsg = "Argument pars must have " + str (self .npars ) + " elements."
106
141
raise ValueError (emsg )
@@ -113,12 +148,23 @@ def _transform_parametersraw(self, pars, in_format, out_format):
113
148
"""Convert parameter values from in_format to out_format.
114
149
115
150
Parameters
116
- pars: Sequence of parameters
117
- in_format: A format defined for this class
118
- out_format: A format defined for this class
151
+ ----------
152
+ pars : array-like
153
+ The sequence of parameters
154
+ in_format : str
155
+ The format defined for this class
156
+ out_format : str
157
+ The format defined for this class
119
158
120
159
Defined Formats
121
- n/a, FromSequence has no parameters"""
160
+ ---------------
161
+ n/a, FromSequence has no parameters
162
+
163
+ Returns
164
+ -------
165
+ array-like
166
+ The sequence of parameters converted to out_format
167
+ """
122
168
temp = np .array (pars )
123
169
124
170
# Convert to intermediate format "internal"
@@ -138,8 +184,17 @@ def _valueraw(self, pars, r):
138
184
"""Return value of polynomial for the given parameters and r values.
139
185
140
186
Parameters
141
- pars: Empty sequence
142
- r: sequence or scalar over which pars is evaluated"""
187
+ ----------
188
+ pars : array-like
189
+ The empty sequence
190
+ r : array-like
191
+ The sequence or scalar over which pars is evaluated
192
+
193
+ Returns
194
+ -------
195
+ float
196
+ The value of the polynomial for the given parameters
197
+ """
143
198
if len (pars ) != self .npars :
144
199
emsg = "Argument pars must have " + str (self .npars ) + " elements."
145
200
raise ValueError (emsg )
@@ -163,7 +218,18 @@ def getmodule(self):
163
218
return __name__
164
219
165
220
def xyrepr (self , var ):
166
- """Safe string output of x and y, compatible with eval()"""
221
+ """Safe string output of x and y, compatible with eval()
222
+
223
+ Parameters
224
+ ----------
225
+ var : array-like
226
+ The sequence or scalar over which to evaluate
227
+
228
+ Returns
229
+ -------
230
+ str
231
+ The x and y values of the given variable
232
+ """
167
233
return "[%s]" % ", " .join ([repr (v ) for v in var ])
168
234
169
235
def readxy (self , filename ):
0 commit comments