Skip to content

Commit 16039d6

Browse files
numpydoc build for ModelCovariance (#84)
* numpydoc build for ModelCovariance * update format type and fix indentation issue
1 parent caab0af commit 16039d6

File tree

1 file changed

+70
-7
lines changed

1 file changed

+70
-7
lines changed

Diff for: src/diffpy/srmise/modelcluster.py

+70-7
Original file line numberDiff line numberDiff line change
@@ -82,10 +82,12 @@ def setcovariance(self, model, cov):
8282
8383
Parameters
8484
----------
85-
model - A ModelParts object
86-
cov - The nxn covariance matrix for n model parameters. If the parameterization includes "fixed"
87-
parameters not included in the covariance matrix, the matrix is expanded to include these
88-
parameters with 0 uncertainty.
85+
model : ModelParts
86+
The ModelParts instance
87+
cov : ndarray
88+
The nxn covariance matrix for n model parameters. If the parameterization includes "fixed"
89+
parameters not included in the covariance matrix, the matrix is expanded to include these
90+
parameters with 0 uncertainty.
8991
"""
9092
tempcov = np.array(cov)
9193

@@ -151,8 +153,10 @@ def transform(self, in_format, out_format, **kwds):
151153
152154
Parameters
153155
----------
154-
in_format - The current format of parameters
155-
out_format - The new format for parameters
156+
in_format : str
157+
The current format of parameters
158+
out_format : str
159+
The new format for parameters
156160
157161
Keywords
158162
--------
@@ -229,6 +233,18 @@ def getcorrelation(self, i, j):
229233
230234
The standard deviation of fixed parameters is 0, in which case the correlation is
231235
undefined, but return 0 for simplicity.
236+
237+
Parameters
238+
----------
239+
i : int
240+
The index of variable in peak mapping
241+
j : int
242+
The index of variable in peak mapping
243+
244+
Returns
245+
-------
246+
float
247+
The correlation between variables i and j
232248
"""
233249
if self.cov is None:
234250
emsg = "Cannot get correlation on undefined covariance matrix."
@@ -257,6 +273,16 @@ def getuncertainty(self, i):
257273
258274
The variable may be specified as an integer, or as a two-component tuple of integers (l, m)
259275
which indicate the mth parameter of modelpart l.
276+
277+
Parameters
278+
----------
279+
i : int
280+
The index of variable in peak mapping
281+
282+
Returns
283+
-------
284+
float
285+
The uncertainty of variable at index i.
260286
"""
261287
(l, m) = i if i in self.pmap else self.ipmap[i]
262288
return np.sqrt(self.getcovariance(i, i))
@@ -266,6 +292,18 @@ def getcovariance(self, i, j):
266292
267293
The variables may be specified as integers, or as a two-component tuple of integers (l, m)
268294
which indicate the mth parameter of modelpart l.
295+
296+
Parameters
297+
----------
298+
i : int
299+
The index of variable in peak mapping
300+
j : int
301+
The index of variable in peak mapping
302+
303+
Returns
304+
-------
305+
float
306+
The covariance between variables at indeex i and j.
269307
"""
270308
if self.cov is None:
271309
emsg = "Cannot get correlation on undefined covariance matrix."
@@ -282,6 +320,16 @@ def get(self, i):
282320
283321
The variable may be specified as an integer, or as a two-component tuple of integers (l, m)
284322
which indicate the mth parameter of modelpart l.
323+
324+
Parameters
325+
----------
326+
i : int
327+
The index of variable in peak mapping
328+
329+
Returns
330+
-------
331+
(float, float)
332+
The value and uncertainty of variable at index i.
285333
"""
286334
return (self.getvalue(i), self.getuncertainty(i))
287335

@@ -294,8 +342,13 @@ def correlationwarning(self, threshold=0.8):
294342
295343
Parameters
296344
----------
297-
threshold - A real number between 0 and 1.
345+
threshold : float
346+
A real number between 0 and 1.
298347
348+
Returns
349+
-------
350+
tuple (i, j, c)
351+
Indices of the modelpart and their correlations.
299352
"""
300353
if self.cov is None:
301354
emsg = "Cannot calculate correlation on undefined covariance matrix."
@@ -323,6 +376,16 @@ def prettypar(self, i):
323376
324377
The variable may be specified as an integer, or as a two-component tuple of integers (l, m)
325378
which indicate the mth parameter of modelpart l.
379+
380+
Parameters
381+
----------
382+
i : int
383+
The index of variable in peak mapping
384+
385+
Returns
386+
-------
387+
str
388+
'value (uncertainty)' for variable at index i.
326389
"""
327390
if self.model is None or self.cov is None:
328391
return "Model and/or Covariance matrix undefined."

0 commit comments

Comments
 (0)