Skip to content

Commit e7e53cb

Browse files
numpydoc build for polynomial.py (#97)
1 parent a66843b commit e7e53cb

File tree

1 file changed

+68
-30
lines changed

1 file changed

+68
-30
lines changed

Diff for: src/diffpy/srmise/baselines/polynomial.py

+68-30
Original file line numberDiff line numberDiff line change
@@ -29,10 +29,13 @@ def __init__(self, degree, Cache=None):
2929
"""Initialize a polynomial function of degree d.
3030
3131
Parameters
32-
degree: The degree of the polynomial. Any negative value is interpreted
33-
as the polynomial of negative infinite degree.
34-
Cache: A class (not instance) which implements caching of BaseFunction
35-
evaluations.
32+
----------
33+
degree: int
34+
The degree of the polynomial. Any negative value is interpreted
35+
as the polynomial of negative infinite degree.
36+
Cache: class
37+
The class (not instance) which implements caching of BaseFunction
38+
evaluations.
3639
"""
3740
# Guarantee valid degree
3841
try:
@@ -62,13 +65,20 @@ def estimate_parameters(self, r, y):
6265
y=baseline+signal, where signal is primarily positive.
6366
6467
Parameters
65-
r: (Numpy array) Data along r from which to estimate
66-
y: (Numpy array) Data along y from which to estimate
67-
68-
Returns Numpy array of parameters in the default internal format.
69-
Raises NotImplementedError if estimation is not implemented for this
70-
degree, or SrMiseEstimationError if parameters cannot be estimated for
71-
any other reason."""
68+
----------
69+
r : array-like
70+
The data along r from which to estimate
71+
y : array-like
72+
The data along y from which to estimate
73+
74+
Returns
75+
-------
76+
array-like
77+
The Numpy array of parameters in the default internal format.
78+
Raises NotImplementedError if estimation is not implemented for this
79+
degree, or SrMiseEstimationError if parameters cannot be estimated for
80+
any other reason.
81+
"""
7282
if self.degree > 1:
7383
emsg = "Polynomial implements estimation for baselines of degree <= 1 only."
7484
raise NotImplementedError(emsg)
@@ -105,14 +115,23 @@ def _jacobianraw(self, pars, r, free):
105115
"""Return the Jacobian of a polynomial.
106116
107117
Parameters
108-
pars: Sequence of parameters for a polynomial of degree d
109-
pars[0] = a_degree
110-
pars[1] = a_(degree-1)
111-
...
112-
pars[d] = a_0
113-
r: sequence or scalar over which pars is evaluated
114-
free: sequence of booleans which determines which derivatives are
115-
needed. True for evaluation, False for no evaluation.
118+
----------
119+
pars : array-like
120+
The sequence of parameters for a polynomial of degree d
121+
pars[0] = a_degree
122+
pars[1] = a_(degree-1)
123+
...
124+
pars[d] = a_0
125+
r : array-like
126+
The sequence or scalar over which pars is evaluated
127+
free : bool
128+
The sequence of booleans which determines which derivatives are
129+
needed. True for evaluation, False for no evaluation.
130+
131+
Returns
132+
-------
133+
jacobian: array-like
134+
The Jacobian of polynomial with degree d
116135
"""
117136
if len(pars) != self.npars:
118137
emsg = "Argument pars must have " + str(self.npars) + " elements."
@@ -135,12 +154,22 @@ def _transform_parametersraw(self, pars, in_format, out_format):
135154
"""Convert parameter values from in_format to out_format.
136155
137156
Parameters
138-
pars: Sequence of parameters
139-
in_format: A format defined for this class
140-
out_format: A format defined for this class
157+
pars : array-like
158+
The sequence of parameters
159+
in_format : str
160+
The format defined for this class
161+
out_format : str
162+
The format defined for this class
141163
142164
Defined Formats
143-
internal: [a_degree, a_(degree-1), ..., a_0]"""
165+
---------------
166+
internal: [a_degree, a_(degree-1), ..., a_0]
167+
168+
Returns
169+
-------
170+
array-like
171+
The transformed parameters in out_format
172+
"""
144173
temp = np.array(pars)
145174

146175
# Convert to intermediate format "internal"
@@ -160,13 +189,22 @@ def _valueraw(self, pars, r):
160189
"""Return value of polynomial for the given parameters and r values.
161190
162191
Parameters
163-
pars: Sequence of parameters for a polynomial of degree d
164-
pars[0] = a_degree
165-
pars[1] = a_(degree-1)
166-
...
167-
pars[d] = a_0
168-
If degree is negative infinity, pars is an empty sequence.
169-
r: sequence or scalar over which pars is evaluated"""
192+
----------
193+
pars : array-like
194+
The sequence of parameters for a polynomial of degree d
195+
pars[0] = a_degree
196+
pars[1] = a_(degree-1)
197+
...
198+
pars[d] = a_0
199+
If degree is negative infinity, pars is an empty sequence.
200+
r : array-like
201+
The sequence or scalar over which pars is evaluated
202+
203+
Returns
204+
-------
205+
float
206+
The value of polynomial for the given parameters and r values.
207+
"""
170208
if len(pars) != self.npars:
171209
emsg = "Argument pars must have " + str(self.npars) + " elements."
172210
raise ValueError(emsg)

0 commit comments

Comments
 (0)