Skip to content

Commit 49abe70

Browse files
committed
docs: use numpy docstring in .py files
1 parent e5d79f6 commit 49abe70

File tree

13 files changed

+224
-102
lines changed

13 files changed

+224
-102
lines changed

news/fix-docstring.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* No news added: Fix documentation rendering.
4+
5+
**Changed:**
6+
7+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/srreal/atomradiitable.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,10 @@ class CovalentRadiiTable(AtomRadiiTable):
3535
def _standardLookup(self, smbl):
3636
"""Return covalent atom radius in Angstroms.
3737
38-
smbl -- string symbol of an element
38+
Attributes
39+
----------
40+
smbl
41+
string symbol of an element
3942
4043
Return float. Raise ValueError for unknown element symbol.
4144
"""

src/diffpy/srreal/bondcalculator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -58,9 +58,13 @@ def _init_kwargs(self, **kwargs):
5858
def _call_kwargs(self, structure=None, **kwargs):
5959
"""Return sorted bond distances in the specified structure.
6060
61-
structure -- structure to be evaluated, an instance of diffpy Structure
62-
or pyobjcryst Crystal. Reuse the last structure when None.
63-
kwargs -- optional parameter settings for this calculator
61+
Attributes
62+
----------
63+
structure
64+
structure to be evaluated, an instance of diffpy Structure
65+
or pyobjcryst Crystal. Reuse the last structure when None.
66+
kwargs
67+
optional parameter settings for this calculator
6468
6569
Return a sorted numpy array.
6670
"""

src/diffpy/srreal/bvscalculator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -75,9 +75,13 @@ def _init_kwargs(self, **kwargs):
7575
def _call_kwargs(self, structure=None, **kwargs):
7676
"""Return bond valence sums at each atom site in the structure.
7777
78-
structure -- structure to be evaluated, an instance of diffpy Structure
79-
or pyobjcryst Crystal. Reuse the last structure when None.
80-
kwargs -- optional parameter settings for this calculator
78+
Attributes
79+
----------
80+
structure
81+
structure to be evaluated, an instance of diffpy Structure
82+
or pyobjcryst Crystal. Reuse the last structure when None.
83+
kwargs
84+
optional parameter settings for this calculator
8185
8286
Return an array of calculated valence sums.
8387
See valences for the expected values.

src/diffpy/srreal/devutils/tunePeakPrecision.py

Lines changed: 36 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,10 @@
5454
def Gpdffit2(qmax):
5555
"""Calculate reference nickel PDF using diffpy.pdffit2.
5656
57-
qmax -- vawevector cutoff value in 1/A
57+
Attributes
58+
----------
59+
qmax
60+
vawevector cutoff value in 1/A
5861
5962
Return numpy array of (r, g).
6063
"""
@@ -70,9 +73,13 @@ def Gpdffit2(qmax):
7073
def Gsrreal(qmax, peakprecision=None):
7174
"""Calculate nickel PDF using PDFCalculator from diffpy.srreal.
7275
73-
qmax -- vawevector cutoff value in 1/A
74-
peakprecision -- precision factor affecting peak cutoff,
75-
keep at default value when None.
76+
Attributes
77+
----------
78+
qmax
79+
vawevector cutoff value in 1/A
80+
peakprecision
81+
precision factor affecting peak cutoff,
82+
keep at default value when None.
7683
7784
Return numpy array of (r, g).
7885
"""
@@ -91,19 +98,30 @@ def Gsrreal(qmax, peakprecision=None):
9198
def comparePDFCalculators(qmax, peakprecision=None):
9299
"""Compare Ni PDF calculations with pdffit2 and PDFCalculator.
93100
94-
qmax -- vawevector cutoff value in 1/A
95-
peakprecision -- precision factor affecting peak cutoff,
96-
keep at default value when None.
101+
Attributes
102+
----------
103+
qmax
104+
vawevector cutoff value in 1/A
105+
peakprecision
106+
precision factor affecting peak cutoff,
107+
keep at default value when None.
97108
98109
Return a dictionary of benchmark results with the following keys:
99110
100-
qmax -- vawevector cutoff value
101-
peakprecision -- actual peak precision used in PDFCalculator
102-
r -- common r-grid for the PDF arrays
103-
g0, g1 -- calculated PDF curves from pdffit2 and PDFCalculator
104-
gdiff -- PDF difference equal (g0 - g1)
105-
grmsd -- root mean square value of PDF curves difference
106-
t0, t1 -- CPU times used by pdffit2 and PDFCalculator calls
111+
Attributes
112+
----------
113+
qmax
114+
vawevector cutoff value
115+
peakprecision
116+
actual peak precision used in PDFCalculator
117+
r
118+
common r-grid for the PDF arrays
119+
g0, g1 -- calculated PDF curves from pdffit2 and PDFCalculator
120+
gdiff
121+
PDF difference equal (g0 - g1)
122+
grmsd
123+
root mean square value of PDF curves difference
124+
t0, t1 -- CPU times used by pdffit2 and PDFCalculator calls
107125
"""
108126
rv = {}
109127
rv["qmax"] = qmax
@@ -147,7 +165,10 @@ def processCommandLineArguments():
147165
def plotComparison(cmpdata):
148166
"""Plot comparison of PDF curves.
149167
150-
cmpdata -- dictionary returned from comparePDFCalculators
168+
Attributes
169+
----------
170+
cmpdata
171+
dictionary returned from comparePDFCalculators
151172
152173
No return value.
153174
"""

src/diffpy/srreal/overlapcalculator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,9 +66,13 @@ def _init_kwargs(self, **kwargs):
6666
def _call_kwargs(self, structure=None, **kwargs):
6767
"""Return siteSquareOverlaps per each site of the structure.
6868
69-
structure -- structure to be evaluated, an instance of diffpy Structure
70-
or pyobjcryst Crystal. Reuse the last structure when None.
71-
kwargs -- optional parameter settings for this calculator
69+
Attributes
70+
----------
71+
structure
72+
structure to be evaluated, an instance of diffpy Structure
73+
or pyobjcryst Crystal. Reuse the last structure when None.
74+
kwargs
75+
optional parameter settings for this calculator
7276
7377
Return a numpy array.
7478
"""

src/diffpy/srreal/parallel.py

Lines changed: 31 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,9 +31,14 @@
3131
def createParallelCalculator(pqobj, ncpu, pmap):
3232
"""Create a proxy parallel calculator to a PairQuantity instance.
3333
34-
pqobj -- instance of PairQuantity calculator to be run in parallel
35-
ncpu -- number of parallel jobs
36-
pmap -- a parallel map function used to submit job to workers
34+
Attributes
35+
----------
36+
pqobj
37+
instance of PairQuantity calculator to be run in parallel
38+
ncpu
39+
number of parallel jobs
40+
pmap
41+
a parallel map function used to submit job to workers
3742
3843
The ``pqobj.evaluatortype`` is reset to 'BASIC' because other
3944
evaluator types are not supported within parallel calculations.
@@ -48,18 +53,28 @@ class to the wrapper PairQuantity type with the same interface.
4853
4954
Instance data:
5055
51-
pqobj -- the master PairQuantity object to be evaluated in parallel
52-
ncpu -- number of parallel jobs
53-
pmap -- a parallel map function used to submit job to workers
56+
Attributes
57+
----------
58+
pqobj
59+
the master PairQuantity object to be evaluated in parallel
60+
ncpu
61+
number of parallel jobs
62+
pmap
63+
a parallel map function used to submit job to workers
5464
"""
5565

5666
def __init__(self, pqobj, ncpu, pmap):
5767
"""Initialize a parallel proxy to the PairQuantity instance.
5868
59-
pqobj -- instance of PairQuantity calculator to be run
60-
in parallel
61-
ncpu -- number of parallel jobs
62-
pmap -- a parallel map function used to submit job to workers
69+
Attributes
70+
----------
71+
pqobj
72+
instance of PairQuantity calculator to be run
73+
in parallel
74+
ncpu
75+
number of parallel jobs
76+
pmap
77+
a parallel map function used to submit job to workers
6378
"""
6479
# use explicit assignment to avoid setattr forwarding to the pqobj
6580
object.__setattr__(self, "pqobj", pqobj)
@@ -73,9 +88,12 @@ def eval(self, stru=None):
7388
"""Perform parallel calculation and return internal value
7489
array.
7590
76-
stru -- object that can be converted to StructureAdapter,
77-
e.g., example diffpy Structure or pyobjcryst Crystal.
78-
Use the last structure when None.
91+
Attributes
92+
----------
93+
stru
94+
object that can be converted to StructureAdapter,
95+
e.g., example diffpy Structure or pyobjcryst Crystal.
96+
Use the last structure when None.
7997
8098
Return numpy array.
8199
"""

src/diffpy/srreal/pdfbaseline.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -52,21 +52,27 @@ def makePDFBaseline(name, fnc, replace=False, **dbattrs):
5252
This is required for using Python function as
5353
PDFCalculator.baseline.
5454
55-
name -- unique string name for registering Python function in the
56-
global registry of PDFBaseline types. This will be the
57-
string identifier for the createByType factory.
58-
fnc -- Python function of a floating point argument and optional
59-
float parameters. The parameters need to be registered as
60-
double attributes in the functor class. The function fnc
61-
must be picklable and it must return a float.
62-
replace -- when set replace any PDFBaseline type already registered
63-
under the name. Otherwise raise RuntimeError when the
64-
name is taken.
65-
dbattrs -- optional float parameters of the wrapped function.
66-
These will be registered as double attributes in the
67-
functor class. The wrapped function must be callable as
68-
fnc(x, **dbattrs). Make sure to pick attribute names that
69-
do not conflict with other PDFCalculator attributes.
55+
Attributes
56+
----------
57+
name
58+
unique string name for registering Python function in the
59+
global registry of PDFBaseline types. This will be the
60+
string identifier for the createByType factory.
61+
fnc
62+
Python function of a floating point argument and optional
63+
float parameters. The parameters need to be registered as
64+
double attributes in the functor class. The function fnc
65+
must be picklable and it must return a float.
66+
replace
67+
when set replace any PDFBaseline type already registered
68+
under the name. Otherwise raise RuntimeError when the
69+
name is taken.
70+
dbattrs
71+
optional float parameters of the wrapped function.
72+
These will be registered as double attributes in the
73+
functor class. The wrapped function must be callable as
74+
fnc(x, **dbattrs). Make sure to pick attribute names that
75+
do not conflict with other PDFCalculator attributes.
7076
7177
Return an instance of the new PDFBaseline class.
7278

src/diffpy/srreal/pdfcalculator.py

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -167,9 +167,13 @@ def _call_kwargs(self, structure=None, **kwargs):
167167
attributes, these override any properties that may be passed
168168
from the structure, such as spdiameter.
169169
170-
structure -- a structure object to be evaluated. Reuse the last
171-
structure when None.
172-
kwargs -- optional parameter settings for this calculator
170+
Attributes
171+
----------
172+
structure
173+
a structure object to be evaluated. Reuse the last
174+
structure when None.
175+
kwargs
176+
optional parameter settings for this calculator
173177
174178
Example: pdfcalc(structure, qmax=20, spdiameter=15)
175179

src/diffpy/srreal/pdfenvelope.py

Lines changed: 21 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -81,21 +81,27 @@ def makePDFEnvelope(name, fnc, replace=False, **dbattrs):
8181
This is required for using Python function as PDFCalculator
8282
envelope.
8383
84-
name -- unique string name for registering Python function in the
85-
global registry of PDFEnvelope types. This will be the
86-
string identifier for the createByType factory.
87-
fnc -- Python function of a floating point argument and optional
88-
float parameters. The parameters need to be registered as
89-
double attributes in the functor class. The function fnc
90-
must be picklable and it must return a float.
91-
replace -- when set replace any PDFEnvelope type already registered
92-
under the name. Otherwise raise RuntimeError when the
93-
name is taken.
94-
dbattrs -- optional float parameters of the wrapped function.
95-
These will be registered as double attributes in the
96-
functor class. The wrapped function must be callable as
97-
fnc(x, **dbattrs). Make sure to pick attribute names that
98-
do not conflict with other PDFCalculator attributes.
84+
Attributes
85+
----------
86+
name
87+
unique string name for registering Python function in the
88+
global registry of PDFEnvelope types. This will be the
89+
string identifier for the createByType factory.
90+
fnc
91+
Python function of a floating point argument and optional
92+
float parameters. The parameters need to be registered as
93+
double attributes in the functor class. The function fnc
94+
must be picklable and it must return a float.
95+
replace
96+
when set replace any PDFEnvelope type already registered
97+
under the name. Otherwise raise RuntimeError when the
98+
name is taken.
99+
dbattrs
100+
optional float parameters of the wrapped function.
101+
These will be registered as double attributes in the
102+
functor class. The wrapped function must be callable as
103+
fnc(x, **dbattrs). Make sure to pick attribute names that
104+
do not conflict with other PDFCalculator attributes.
99105
100106
Return an instance of the new PDFEnvelope class.
101107

0 commit comments

Comments
 (0)