Skip to content

Commit 6942139

Browse files
authored
Merge pull request #91 from Sparks29032/docs_build
Docstring Reformatting
2 parents fbef88e + d7ea16d commit 6942139

20 files changed

+553
-390
lines changed

.travis.yml

Lines changed: 0 additions & 53 deletions
This file was deleted.

doc/source/conf.py

Lines changed: 23 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -13,27 +13,44 @@
1313
import sys
1414
import os
1515
sys.path.insert(0, os.path.abspath('../..'))
16+
sys.path.insert(0, os.path.abspath('../../src'))
1617

1718

1819
# -- Project information -----------------------------------------------------
1920

2021
project = 'PDFmorph'
22+
project_full = 'diffpy.pdfmorph'
2123
copyright = '2009-2019, Trustees of Columbia University in the City of New York, all rights reserved.'
2224
author = 'Chris Farrow, Christopher J. Wright, Pavol Juhás, Chia-Hao (Timothy) Liu, S. Matthew Román, Simon J.L. Billinge'
2325

2426
# The full version, including alpha/beta/rc tags
25-
release = '0.1.0'
27+
from importlib.metadata import version
28+
fullversion = version(project_full)
29+
# The short X.Y version.
30+
version = ''.join(fullversion.split('.post')[:1])
31+
# The full version, including alpha/beta/rc tags.
32+
release = fullversion
33+
34+
# Get current date for copyright
35+
import time
36+
today = time.strftime('%B %d, %Y', time.localtime())
37+
year = today.split()[-1]
38+
copyright = copyright.replace('%Y', year)
2639

2740

2841
# -- General configuration ---------------------------------------------------
2942

3043
# Add any Sphinx extension module names here, as strings. They can be
3144
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
3245
# ones.
33-
import sphinx_rtd_theme
34-
extensions = ['sphinx.ext.autodoc', 'sphinx.ext.napoleon',
35-
'sphinx.ext.todo', 'sphinx.ext.viewcode',
36-
'sphinx.ext.intersphinx', 'm2r']
46+
extensions = ['sphinx.ext.autodoc',
47+
'sphinx.ext.napoleon',
48+
'sphinx.ext.todo',
49+
'sphinx.ext.viewcode',
50+
'sphinx.ext.intersphinx',
51+
'sphinx_rtd_theme',
52+
'm2r',
53+
]
3754
napoleon_google_docstring = False
3855
napoleon_use_param = False
3956
napoleon_use_ivar = False
@@ -61,6 +78,7 @@
6178

6279
# The theme to use for HTML and HTML Help pages. See the documentation for
6380
# a list of builtin themes.
81+
import sphinx_rtd_theme
6482
html_theme = 'sphinx_rtd_theme'
6583
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
6684

doc/source/morph_helpers.rst

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
PDFmorph.morph_helpers Package
2-
#######################
2+
##############################
33

44
diffpy.pdfmorph.morph_helpers.transformpdftordf module
5-
===========================================
5+
======================================================
66

77
.. automodule:: diffpy.pdfmorph.morph_helpers.transformpdftordf
88
:members:
99
:undoc-members:
1010
:show-inheritance:
1111

1212
diffpy.pdfmorph.morph_helpers.transformrdftopdf module
13-
===========================================
13+
======================================================
1414

1515
.. automodule:: diffpy.pdfmorph.morph_helpers.transformrdftopdf
1616
:members:

doc/source/quickstart.rst

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,10 @@ Basic PDFmorph Workflow
3434
explore in this tutorial.
3535

3636
3. Using the ``mkdir`` command, create a directory where you'll
37-
store the tutorial PDF files and use the ``cd`` command to change
38-
into that directory. You can download the tutorial files
39-
:download:`here <../../tests/testdata/tutorialData.zip>`.
40-
Then, ``cd`` into the ``tutorialData`` directory.
37+
store the tutorial PDF files and use the ``cd`` command to change
38+
into that directory. You can download the tutorial files
39+
:download:`here <../../tutorial/tutorialData.zip>`.
40+
Then, ``cd`` into the ``tutorialData`` directory.
4141

4242
* The files in this dataset were collected by Soham Banerjee
4343
at Brookhaven National Laboratory in Upton, New York.

src/diffpy/pdfmorph/log.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,13 @@
2929
def set_verbosity(vb):
3030
'''Set verbosity of the pdfmorph logger.
3131
32-
vb -- integer or one of ('debug', 'info', 'warning', 'error') strings
32+
Parameters
33+
----------
34+
vb
35+
Integer or one of ('debug', 'info', 'warning', 'error') strings.
3336
37+
Returns
38+
-------
3439
No return value.
3540
'''
3641
try:

src/diffpy/pdfmorph/morphs/morph.py

Lines changed: 110 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -26,41 +26,59 @@
2626
class Morph(object):
2727
'''Base class for implementing a morph given a target.
2828
29-
Adapted from diffpy.pdfgetx to include two sets of arrays that get passed
30-
through.
31-
32-
Note that attributes are taken from config when not found locally. The
33-
morph may modify the config dictionary. This is the means by which to
34-
communicate automatically modified attributes.
35-
36-
Class attributes:
37-
38-
summary -- short description of a morph
39-
xinlabel -- descriptive label for the x input array
40-
yinlabel -- descriptive label for the y input array
41-
xoutlabel -- descriptive label for the x output array
42-
youtlabel -- descriptive label for the y output array
43-
parnames -- list of names of configuration variables
44-
45-
Instance attributes:
46-
47-
config -- dictionary that contains all configuration variables
48-
x_morph_in -- last morph input x data
49-
y_morph_in -- last morph input y data
50-
x_morph_out -- last morph result x data
51-
y_morph_out -- last morph result y data
52-
x_target_in -- last target input x data
53-
y_target_in -- last target input y data
54-
x_target_out -- last target result x data
55-
y_target_out -- last target result y data
56-
57-
Properties:
58-
59-
xy_morph_in -- tuple of (x_morph_in, y_morph_in)
60-
xy_morph_out -- tuple of (x_morph_out, y_morph_out)
61-
xy_target_in -- tuple of (x_target_in, y_target_in)
62-
xy_target_out -- tuple of (x_target_out, y_target_out)
63-
xyallout -- tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out)
29+
Adapted from diffpy.pdfgetx to include two sets of arrays that get passed through.
30+
31+
Attributes are taken from config when not found locally. The morph may modify the config dictionary.
32+
This is the means by which to communicate automatically modified attributes.
33+
34+
Class Attributes
35+
----------------
36+
summary
37+
Short description of a morph.
38+
xinlabel
39+
Descriptive label for the x input array.
40+
yinlabel
41+
Descriptive label for the y input array.
42+
xoutlabel
43+
Descriptive label for the x output array.
44+
youtlabel
45+
Descriptive label for the y output array.
46+
parnames: list
47+
Names of configuration variables.
48+
49+
Instance Attributes
50+
-------------------
51+
config: dict
52+
All configuration variables.
53+
x_morph_in
54+
Last morph input x data.
55+
y_morph_in
56+
Last morph input y data.
57+
x_morph_out
58+
Last morph result x data.
59+
y_morph_out
60+
Last morph result y data.
61+
x_target_in
62+
Last target input x data.
63+
y_target_in
64+
Last target input y data.
65+
x_target_out
66+
Last target result x data.
67+
y_target_out
68+
Last target result y data.
69+
70+
Properties
71+
----------
72+
xy_morph_in
73+
Tuple of (x_morph_in, y_morph_in).
74+
xy_morph_out
75+
Tuple of (x_morph_out, y_morph_out).
76+
xy_target_in
77+
Tuple of (x_target_in, y_target_in).
78+
xy_target_out
79+
Tuple of (x_target_out, y_target_out).
80+
xyallout
81+
Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out).
6482
'''
6583

6684
# Class variables
@@ -98,7 +116,8 @@ class Morph(object):
98116
def __init__(self, config=None):
99117
'''Create a default Morph instance.
100118
101-
config -- dictionary that contains all configuration variables
119+
config: dict
120+
All configuration variables.
102121
'''
103122
# declare empty attributes
104123
if config is None:
@@ -118,13 +137,19 @@ def __init__(self, config=None):
118137
def morph(self, x_morph, y_morph, x_target, y_target):
119138
'''Morph arrays morphed or target.
120139
121-
x_morph, y_morph -- Morphed arrays.
122-
x_target, y_target -- Target arrays.
140+
Identity operation. This method should be overloaded in a derived class.
123141
124-
Identity operation. This method should be overloaded in a derived
125-
class.
142+
Parameters
143+
----------
144+
x_morph, y_morph
145+
Morphed arrays.
146+
x_target, y_target
147+
Target arrays.
126148
127-
Return a tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)
149+
Returns
150+
-------
151+
tuple
152+
A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)
128153
'''
129154
self.x_morph_in = x_morph
130155
self.y_morph_in = y_morph
@@ -144,15 +169,20 @@ def __call__(self, x_morph, y_morph, x_target, y_target):
144169
def applyConfig(self, config):
145170
'''Process any configuration data from a dictionary.
146171
147-
config -- Configuration dictionary.
172+
Parameters
173+
----------
174+
config: dict
175+
Configuration dictionary.
148176
177+
Returns
178+
-------
149179
No return value.
150180
'''
151181
self.config = config
152182
return
153183

154184
def checkConfig(self):
155-
'''Verify data in self.config. No action by default.
185+
'''Verify data in self.config. No action by default.
156186
157187
To be overridden in a derived class.
158188
'''
@@ -161,9 +191,15 @@ def checkConfig(self):
161191
def plotInputs(self, xylabels=True):
162192
'''Plot input arrays using matplotlib.pyplot
163193
164-
xylabels -- flag for updating x and y axes labels
194+
Parameters
195+
----------
196+
xylabels
197+
Flag for updating x and y axes labels.
165198
166-
Return a list of matplotlib line objects.
199+
Returns
200+
-------
201+
list:
202+
A list of matplotlib line objects.
167203
'''
168204
from matplotlib.pyplot import plot, xlabel, ylabel
169205

@@ -177,11 +213,17 @@ def plotInputs(self, xylabels=True):
177213
def plotOutputs(self, xylabels=True, **plotargs):
178214
'''Plot output arrays using matplotlib.pyplot
179215
180-
xylabels -- flag for updating x and y axes labels
181-
plotargs -- arguments passed to the pylab plot function. Note that
182-
"label" will be ignored.
183-
184-
Return a list of matplotlib line objects.
216+
Parameters
217+
----------
218+
xylabels: bool
219+
Flag for updating x and y axes labels.
220+
plotargs
221+
Arguments passed to the pylab plot function. Note that "label" will be ignored.
222+
223+
Returns
224+
-------
225+
list
226+
A list of matplotlib line objects.
185227
'''
186228
from matplotlib.pyplot import plot, xlabel, ylabel
187229

@@ -197,10 +239,19 @@ def plotOutputs(self, xylabels=True, **plotargs):
197239
def __getattr__(self, name):
198240
'''Obtain the value from self.config, when normal lookup fails.
199241
200-
name -- name of the attribute to be recovered
242+
Parameters
243+
----------
244+
name
245+
Name of the attribute to be recovered.
246+
247+
Returns
248+
-------
249+
self.config.get(name)
201250
202-
Return self.config.get(name).
203-
Raise AttributeError, when name is not available from self.config.
251+
Raises
252+
------
253+
AttributeError
254+
Name is not available from self.config.
204255
'''
205256
if name in self.config:
206257
return self.config[name]
@@ -211,9 +262,12 @@ def __getattr__(self, name):
211262
def __setattr__(self, name, val):
212263
'''Set configuration variables to config.
213264
214-
name -- name of the attribute
215-
val -- value of the attribute
216-
265+
Parameters
266+
----------
267+
name
268+
Name of the attribute.
269+
val
270+
Value of the attribute.
217271
'''
218272
if name in self.parnames:
219273
self.config[name] = val

0 commit comments

Comments
 (0)