Skip to content

Commit def4a2d

Browse files
numpydoc build for pdfdataset (#88)
1 parent 4d3d8ff commit def4a2d

File tree

1 file changed

+107
-47
lines changed

1 file changed

+107
-47
lines changed

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

+107-47
Original file line numberDiff line numberDiff line change
@@ -32,48 +32,67 @@ class PDFComponent(object):
3232
"""Common base class."""
3333

3434
def __init__(self, name):
35-
"""initialize
35+
"""initialize the object
3636
37-
name -- object name
37+
Parameter
38+
---------
39+
name : str
40+
object name
3841
"""
3942
self.name = name
4043

4144
def close(self, force=False):
4245
"""close myself
4346
44-
force -- if forcibly (no wait)
47+
Parameter
48+
---------
49+
force : bool
50+
Force to close if True, default is False.
4551
"""
4652
pass
4753

4854

4955
class PDFDataSet(PDFComponent):
5056
"""PDFDataSet is a class for experimental PDF data.
5157
52-
Data members:
53-
robs -- list of observed r points
54-
Gobs -- list of observed G values
55-
drobs -- list of standard deviations of robs
56-
dGobs -- list of standard deviations of Gobs
57-
stype -- scattering type, 'X' or 'N'
58-
qmax -- maximum value of Q in inverse Angstroms. Termination
59-
ripples are neglected for qmax=0.
60-
qdamp -- specifies width of Gaussian damping factor in pdf_obs due
61-
to imperfect Q resolution
62-
qbroad -- quadratic peak broadening factor related to dataset
63-
spdiameter -- particle diameter for shape damping function
64-
Note: This attribute was moved to PDFStructure.
65-
It is kept for backward compatibility when reading
66-
PDFgui project files.
67-
dscale -- scale factor of this dataset
68-
rmin -- same as robs[0]
69-
rmax -- same as robs[-1]
70-
filename -- set to absolute path after reading from file
71-
metadata -- dictionary for other experimental conditions, such as
72-
temperature or doping
73-
74-
Global member:
75-
persistentItems -- list of attributes saved in project file
76-
refinableVars -- set (dict) of refinable variable names.
58+
Attributes
59+
----------
60+
robs : list
61+
The list of observed r points.
62+
Gobs : list
63+
The list of observed G values.
64+
drobs : list
65+
The list of standard deviations of `robs`.
66+
dGobs : list
67+
The list of standard deviations of `Gobs`.
68+
stype : str
69+
The scattering type, either 'X' or 'N'.
70+
qmax : float
71+
The maximum value of Q in inverse Angstroms. Termination ripples are neglected for qmax=0.
72+
qdamp : float
73+
Specifies width of Gaussian damping factor in pdf_obs due to imperfect Q resolution.
74+
qbroad : float
75+
The quadratic peak broadening factor related to the dataset.
76+
spdiameter : float
77+
The particle diameter for shape damping function. Note: This attribute was moved to PDFStructure.
78+
It is retained here for backward compatibility when reading PDFgui project files.
79+
dscale : float
80+
The scale factor of this dataset.
81+
rmin : float
82+
The same as `robs[0]`.
83+
rmax : float
84+
The same as `robs[-1]`.
85+
filename : str
86+
Set to the absolute path after reading from a file.
87+
metadata : dict
88+
The dictionary for other experimental conditions, such as temperature or doping.
89+
90+
Class Members
91+
-------------
92+
persistentItems : list
93+
The list of attributes saved in the project file.
94+
refinableVars : set
95+
The set (or dict-like) of refinable variable names.
7796
"""
7897

7998
persistentItems = [
@@ -95,14 +114,17 @@ class PDFDataSet(PDFComponent):
95114
def __init__(self, name):
96115
"""Initialize.
97116
98-
name -- name of the data set. It must be a unique identifier.
117+
name : str
118+
The name of the data set. It must be a unique identifier.
99119
"""
100120
PDFComponent.__init__(self, name)
101121
self.clear()
102122
return
103123

104124
def clear(self):
105-
"""reset all data members to initial empty values"""
125+
"""reset all data members to initial empty values
126+
127+
The purpose of this method is to set the PDF dataset to initial empty values."""
106128
self.robs = []
107129
self.Gobs = []
108130
self.drobs = []
@@ -121,12 +143,21 @@ def clear(self):
121143
return
122144

123145
def setvar(self, var, value):
124-
"""Assign data member using PdfFit-style variable.
125-
Used by applyParameters().
146+
"""Assign a data member using PdfFit-style variable notation.
147+
This method is typically utilized by the `applyParameters()` function.
148+
149+
Parameters
150+
----------
151+
var : str
152+
String representation of the dataset PdfFit variable.
153+
Possible values include: 'qdamp', 'qbroad', 'dscale'.
154+
155+
value : float
156+
The new value to which the variable `var` will be set.
126157
127-
var -- string representation of dataset PdfFit variable.
128-
Possible values: qdamp, qbroad, dscale
129-
value -- new value of the variable
158+
Returns
159+
-------
160+
None
130161
"""
131162
barevar = var.strip()
132163
fvalue = float(value)
@@ -141,10 +172,16 @@ def getvar(self, var):
141172
"""Obtain value corresponding to PdfFit dataset variable.
142173
Used by findParameters().
143174
144-
var -- string representation of dataset PdfFit variable.
145-
Possible values: qdamp, qbroad, dscale
175+
Parameters
176+
----------
177+
var : str
178+
string representation of dataset PdfFit variable.
179+
Possible values: qdamp, qbroad, dscale
146180
147-
returns value of var
181+
Returns
182+
-------
183+
float
184+
value of var
148185
"""
149186
barevar = var.strip()
150187
if barevar in PDFDataSet.refinableVars:
@@ -157,9 +194,12 @@ def getvar(self, var):
157194
def read(self, filename):
158195
"""load data from PDFGetX2 or PDFGetN gr file
159196
160-
filename -- file to read from
197+
filename : str
198+
file to read from
161199
162-
returns self
200+
Returns
201+
-------
202+
self
163203
"""
164204
try:
165205
self.readStr(open(filename, "rb").read())
@@ -176,9 +216,13 @@ def read(self, filename):
176216
def readStr(self, datastring):
177217
"""read experimental PDF data from a string
178218
179-
datastring -- string of raw data
219+
Parameter
220+
---------
221+
datastring : str
222+
string of raw data
180223
181-
returns self
224+
Returns
225+
self
182226
"""
183227
self.clear()
184228
# useful regex patterns:
@@ -299,9 +343,14 @@ def readStr(self, datastring):
299343
def write(self, filename):
300344
"""Write experimental PDF data to a file.
301345
302-
filename -- name of file to write to
346+
Parameters
347+
----------
348+
filename : str
349+
name of file to write to
303350
304-
No return value.
351+
Returns
352+
-------
353+
None
305354
"""
306355
bytes = self.writeStr()
307356
f = open(filename, "w")
@@ -312,7 +361,11 @@ def write(self, filename):
312361
def writeStr(self):
313362
"""String representation of experimental PDF data.
314363
315-
Return data string.
364+
365+
Returns
366+
-------
367+
str
368+
The PDF data string.
316369
"""
317370
lines = []
318371
# write metadata
@@ -357,8 +410,15 @@ def writeStr(self):
357410
def copy(self, other=None):
358411
"""copy self to other. if other is None, create new instance
359412
360-
other -- ref to other object
361-
returns reference to copied object
413+
Parameters
414+
----------
415+
other : PDFDataSet instance
416+
ref to other object
417+
418+
Returns
419+
-------
420+
PDFDataSet instance
421+
reference to copied object
362422
"""
363423
if other is None:
364424
other = PDFDataSet(self.name)

0 commit comments

Comments
 (0)