Skip to content

Commit bb71671

Browse files
numpydoc build for nanospherical.py (#98)
1 parent 608a1c1 commit bb71671

File tree

1 file changed

+94
-28
lines changed

1 file changed

+94
-28
lines changed

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

+94-28
Original file line numberDiff line numberDiff line change
@@ -42,8 +42,10 @@ def __init__(self, Cache=None):
4242
"""Initialize a spherical nanoparticle baseline.
4343
4444
Parameters
45-
Cache - A class (not instance) which implements caching of BaseFunction
46-
evaluations.
45+
----------
46+
Cache : class
47+
THe class (not instance) which implements caching of BaseFunction
48+
evaluations.
4749
"""
4850
# Define parameterdict
4951
parameterdict = {"scale": 0, "radius": 1}
@@ -74,12 +76,21 @@ def _jacobianraw(self, pars, r, free):
7476
"""Return the Jacobian of the spherical baseline.
7577
7678
Parameters
77-
pars - Sequence of parameters for a spherical baseline
78-
pars[0] = scale
79-
pars[1] = radius
80-
r - sequence or scalar over which pars is evaluated.
81-
free - sequence of booleans which determines which derivatives are
82-
needed. True for evaluation, False for no evaluation.
79+
----------
80+
pars : array-like
81+
The Sequence of parameters for a spherical baseline
82+
pars[0] = scale
83+
pars[1] = radius
84+
r : array-like
85+
The sequence or scalar over which pars is evaluated.
86+
free : bool
87+
The sequence of booleans which determines which derivatives are
88+
needed. True for evaluation, False for no evaluation.
89+
90+
Returns
91+
-------
92+
array-like
93+
The Jacobian of the nanospherical baseline.
8394
"""
8495
if len(pars) != self.npars:
8596
emsg = "Argument pars must have " + str(self.npars) + " elements."
@@ -116,10 +127,18 @@ def _jacobianrawscale(self, pars, r):
116127
"""Return partial Jacobian wrt scale without bounds checking.
117128
118129
Parameters
119-
pars - Sequence of parameters for a spherical baseline
120-
pars[0] = scale
121-
pars[1] = radius
122-
r - sequence or scalar over which pars is evaluated.
130+
----------
131+
pars : array-like
132+
The sequence of parameters for a spherical baseline
133+
pars[0] = scale
134+
pars[1] = radius
135+
r : array-like
136+
The sequence or scalar over which pars is evaluated.
137+
138+
Returns
139+
-------
140+
array-like
141+
The partial Jacobian of the nanoparticle baseline wrt scale without bounds checking.
123142
"""
124143
np.abs(pars[0])
125144
R = np.abs(pars[1])
@@ -134,10 +153,18 @@ def _jacobianrawradius(self, pars, r):
134153
"""Return partial Jacobian wrt radius without bounds checking.
135154
136155
Parameters
137-
pars - Sequence of parameters for a spherical baseline
138-
pars[0] = scale
139-
pars[1] = radius
140-
r - sequence or scalar over which pars is evaluated.
156+
----------
157+
pars : array-like
158+
The Sequence of parameters for a spherical baseline
159+
pars[0] = scale
160+
pars[1] = radius
161+
r : array-like
162+
The sequence or scalar over which pars is evaluated.
163+
164+
Returns
165+
-------
166+
array-like
167+
The partial Jacobian of the nanoparticle baseline wrt radius without bounds checking.
141168
"""
142169
s = np.abs(pars[0])
143170
R = np.abs(pars[1])
@@ -150,12 +177,22 @@ def _transform_parametersraw(self, pars, in_format, out_format):
150177
"""Convert parameter values from in_format to out_format.
151178
152179
Parameters
153-
pars - Sequence of parameters
154-
in_format - A format defined for this class
155-
out_format - A format defined for this class
180+
----------
181+
pars : array-like
182+
The sequence of parameters
183+
in_format : str
184+
The format defined for this class
185+
out_format : str
186+
The format defined for this class
156187
157188
Defined Formats
189+
---------------
158190
internal - [scale, radius]
191+
192+
Returns
193+
-------
194+
array-like
195+
The transformed parameter values with out_format.
159196
"""
160197
temp = np.array(pars)
161198

@@ -180,10 +217,18 @@ def _valueraw(self, pars, r):
180217
Outside the interval [0, radius] the baseline is 0.
181218
182219
Parameters
183-
pars - Sequence of parameters for a spherical baseline
184-
pars[0] = scale
185-
pars[1] = radius
186-
r - sequence or scalar over which pars is evaluated.
220+
----------
221+
pars : array-like
222+
The sequence of parameters for a spherical baseline
223+
pars[0] = scale
224+
pars[1] = radius
225+
r : array-like
226+
The sequence or scalar over which pars is evaluated.
227+
228+
Returns
229+
-------
230+
float
231+
The value of the spherical baseline.
187232
"""
188233
if len(pars) != self.npars:
189234
emsg = "Argument pars must have " + str(self.npars) + " elements."
@@ -203,18 +248,39 @@ def _valueraw2(self, pars, r):
203248
"""Return value of spherical baseline without bounds checking for given parameters and r values.
204249
205250
Parameters
206-
pars - Sequence of parameters for a spherical baseline
207-
pars[0] = scale
208-
pars[1] = radius
209-
r - sequence or scalar over which pars is evaluated.
251+
----------
252+
pars : array-like
253+
The sequence of parameters for a spherical baseline
254+
pars[0] = scale
255+
pars[1] = radius
256+
r : array-like
257+
The sequence or scalar over which pars is evaluated.
258+
259+
Returns
260+
-------
261+
float
262+
The value of spherical baseline without bounds checking for given parameters and r values
210263
"""
211264
s = np.abs(pars[0])
212265
R = np.abs(pars[1])
213266
rdivR = r / R
214267
return -s * r * (1 - (3.0 / 4.0) * rdivR + (1.0 / 16.0) * rdivR**3)
215268

216269
def _getdomain(self, pars, r):
217-
"""Return slice object for which r > 0 and r < twice the radius"""
270+
"""Return slice object for which r > 0 and r < twice the radius
271+
272+
Parameters
273+
----------
274+
pars : array-like
275+
The sequence of parameters for a spherical baseline
276+
r : array-like
277+
The sequence or scalar over which pars is evaluated.
278+
279+
Returns
280+
-------
281+
slice object
282+
The slice object for which r > 0 and r < twice the radius
283+
"""
218284
low = r.searchsorted(0.0, side="right")
219285
high = r.searchsorted(2.0 * pars[1], side="left")
220286
return slice(low, high)

0 commit comments

Comments
 (0)