Skip to content

Commit 9b197e4

Browse files
committed
style: apply manual editing to shorten the line width
1 parent 3b662ec commit 9b197e4

File tree

15 files changed

+305
-153
lines changed

15 files changed

+305
-153
lines changed

news/line79.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* <news item>
4+
5+
**Changed:**
6+
7+
* reduce the line width limit to 79
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/pdfmorph/morph_helpers/__init__.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,8 @@
1111
#
1212
##############################################################################
1313

14-
"""List of helpers for certain morphing operations (currently only used for smear)."""
14+
"""List of helpers for certain morphing operations
15+
(currently only used for smear)."""
1516

1617
from diffpy.pdfmorph.morph_helpers.transformpdftordf import (
1718
TransformXtalPDFtoRDF,

src/diffpy/pdfmorph/morphs/morph.py

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -26,10 +26,12 @@
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 through.
29+
Adapted from diffpy.pdfgetx to include two sets of arrays that get passed
30+
through.
3031
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.
32+
Attributes are taken from config when not found locally. The morph may
33+
modify the config dictionary. This is the means by which to communicate
34+
automatically modified attributes.
3335
3436
Class Attributes
3537
----------------
@@ -142,7 +144,8 @@ def __init__(self, config=None):
142144
def morph(self, x_morph, y_morph, x_target, y_target):
143145
"""Morph arrays morphed or target.
144146
145-
Identity operation. This method should be overloaded in a derived class.
147+
Identity operation.
148+
This method should be overloaded in a derived class.
146149
147150
Parameters
148151
----------
@@ -154,7 +157,8 @@ def morph(self, x_morph, y_morph, x_target, y_target):
154157
Returns
155158
-------
156159
tuple
157-
A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out)
160+
A tuple of numpy arrays
161+
(x_morph_out, y_morph_out, x_target_out, y_target_out)
158162
"""
159163
self.x_morph_in = x_morph
160164
self.y_morph_in = y_morph
@@ -223,7 +227,8 @@ def plotOutputs(self, xylabels=True, **plotargs):
223227
xylabels: bool
224228
Flag for updating x and y axes labels.
225229
plotargs
226-
Arguments passed to the pylab plot function. Note that "label" will be ignored.
230+
Arguments passed to the pylab plot function.
231+
Note that "label" will be ignored.
227232
228233
Returns
229234
-------

src/diffpy/pdfmorph/morphs/morphchain.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -20,8 +20,9 @@
2020
class MorphChain(list):
2121
"""Class for chaining morphs together.
2222
23-
This class is a queue of morphs that get executed in order via the 'morph' method.
24-
This class derives from the built-in list, and list methods are used to modify the queue.
23+
This class is a queue of morphs that get executed in order via the 'morph'
24+
method. This class derives from the built-in list, and list methods are
25+
used to modify the queue.
2526
2627
This derives from list and relies on its methods where possible.
2728
@@ -57,7 +58,8 @@ class MorphChain(list):
5758
xy_target_out
5859
Tuple of (x_target_out, y_target_out) from last morph.
5960
xyallout
60-
Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out) from last morph.
61+
Tuple of (x_morph_out, y_morph_out, x_target_out, y_target_out)
62+
from last morph.
6163
parnames
6264
Names of parameters collected from morphs (Read only).
6365
@@ -117,7 +119,8 @@ def __init__(self, config, *args):
117119
118120
Notes
119121
-----
120-
Additional arguments are morphs that will extend the queue of morphs.
122+
Additional arguments are morphs that will extend the queue of
123+
morphs.
121124
"""
122125
self.config = config
123126
self.extend(args)
@@ -136,7 +139,8 @@ def morph(self, x_morph, y_morph, x_target, y_target):
136139
Returns
137140
-------
138141
tuple
139-
A tuple of numpy arrays (x_morph_out, y_morph_out, x_target_out, y_target_out).
142+
A tuple of numpy arrays
143+
(x_morph_out, y_morph_out, x_target_out, y_target_out).
140144
141145
Notes
142146
-----

src/diffpy/pdfmorph/morphs/morphrgrid.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,9 +43,10 @@ class MorphRGrid(Morph):
4343
4444
Notes
4545
-----
46-
If any of these is not defined or outside the bounds of the input arrays,
47-
then it will be taken to be the most inclusive value from the input arrays.
48-
These modified values will be stored as the above attributes.
46+
If any of these is not defined or outside the bounds of the input
47+
arrays, then it will be taken to be the most inclusive value from the
48+
input arrays. These modified values will be stored as the above
49+
attributes.
4950
"""
5051

5152
# Define input output types

src/diffpy/pdfmorph/morphs/morphshape.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,8 @@ def morph(self, x_morph, y_morph, x_target, y_target):
8989
def _sphericalCF(r, psize):
9090
"""Spherical nanoparticle characteristic function.
9191
92-
From Kodama et al., Acta Cryst. A, 62, 444-453 (converted from radius to diameter).
92+
From Kodama et al., Acta Cryst. A, 62, 444-453
93+
(converted from radius to diameter).
9394
9495
Parameters
9596
----------

src/diffpy/pdfmorph/pdfmorph_api.py

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -143,7 +143,8 @@ def pdfmorph(
143143
144144
- morph_chain: diffpy.pdfmorph.morphs.morphchain.MorphChain
145145
The instance of processed morph chain.
146-
Calling ``x_morph, y_morph, x_target, y_target = morph_chain.xyallout``
146+
Calling
147+
``x_morph, y_morph, x_target, y_target = morph_chain.xyallout``
147148
will conveniently return morphed data and reference data
148149
- morphed_cfg: dict
149150
A dictionary of refined morphing parameters
@@ -156,8 +157,9 @@ def pdfmorph(
156157
157158
Examples
158159
--------
159-
# morphing (x_morph, y_morph) pair to (x_target, y_target) pair with scaling
160-
from diffpy.pdfmorph.pdfmorph_api import pdfmorph, morph_default_config, plot_morph
160+
# morphing (x_morph, y_morph) pair to (x_target, y_target) pair with
161+
scaling from diffpy.pdfmorph.pdfmorph_api import pdfmorph,
162+
morph_default_config, plot_morph
161163
162164
morph_cfg = morph_default_config(scale=1.01)
163165
morph_rv_dict = pdfmorph(x_morph, y_morph, x_target, y_target, **morph_cfg)
@@ -258,14 +260,16 @@ def plot_morph(chain, ax=None, **kwargs):
258260
An instance of processed morph chain.
259261
ax: matplotlib.axes.Axes, optional
260262
An instance of Axes class to plot the morphing result.
261-
If ax is None, instances of new Figure and Axes will be created. Default to None.
263+
If ax is None, instances of new Figure and Axes will be created.
264+
Default to None.
262265
kwargs:
263266
Additional keyword arguments will be passed to ``ax.plot(...**kwargs)``
264267
265268
Returns
266269
-------
267270
l_list: list
268-
A list of ``matplotlib.lines.Line2D`` objects representing the plotted data.
271+
A list of ``matplotlib.lines.Line2D`` objects representing the
272+
plotted data.
269273
"""
270274
if ax is None:
271275
fig, ax = plt.subplots()

src/diffpy/pdfmorph/pdfmorph_io.py

Lines changed: 39 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -46,10 +46,11 @@ def single_morph_output(
4646
save_file
4747
Name of file to print to. If None (default) print to terminal.
4848
morph_file
49-
Name of the morphed PDF file. Required when printing to a non-terminal file.
49+
Name of the morphed PDF file. Required when printing to a
50+
non-terminal file.
5051
param xy_out: list
51-
List of the form [x_morph_out, y_morph_out]. x_morph_out is a List of r values and
52-
y_morph_out is a List of gr values.
52+
List of the form [x_morph_out, y_morph_out]. x_morph_out is a List of
53+
r values and y_morph_out is a List of gr values.
5354
verbose: bool
5455
Print additional details about the morph when True (default False).
5556
stdout_flag: bool
@@ -107,14 +108,16 @@ def single_morph_output(
107108
def create_morphs_directory(save_directory):
108109
"""Create a directory for saving multiple morphed PDFs.
109110
110-
Takes in a user-given path to a directory save_directory and create a subdirectory named Morphs.
111-
PDFmorph will save all morphs into the Morphs subdirectory while metadata about the morphs will
112-
be stored in save_directory outside Morphs.
111+
Takes in a user-given path to a directory save_directory and create a
112+
subdirectory named Morphs. PDFmorph will save all morphs into the Morphs
113+
subdirectory while metadata about the morphs will be stored in
114+
save_directory outside Morphs.
113115
114116
Parameters
115117
----------
116118
save_directory
117-
Path to a directory. PDFmorph will save all generated files within this directory.
119+
Path to a directory. PDFmorph will save all generated files within
120+
this directory.
118121
119122
Returns
120123
-------
@@ -133,8 +136,9 @@ def create_morphs_directory(save_directory):
133136

134137
def get_multisave_names(target_list: list, save_names_file=None, mm=False):
135138
"""Create or import a dictionary that specifies names to save morphs as.
136-
First attempt to import names from a specified file. If names for certain morphs not found,
137-
use default naming scheme: 'Morph_with_Target_<target file name>.cgr'.
139+
First attempt to import names from a specified file.
140+
If names for certain morphs not found, use default naming scheme:
141+
'Morph_with_Target_<target file name>.cgr'.
138142
139143
Used when saving multiple morphs.
140144
@@ -150,7 +154,8 @@ def get_multisave_names(target_list: list, save_names_file=None, mm=False):
150154
Returns
151155
-------
152156
dict
153-
The names to save each morph as. Keys are the target PDF file names used to produce that morph.
157+
The names to save each morph as. Keys are the target PDF file names
158+
used to produce that morph.
154159
"""
155160

156161
# Dictionary storing save file names
@@ -167,15 +172,19 @@ def get_multisave_names(target_list: list, save_names_file=None, mm=False):
167172
save_names.update(
168173
{
169174
target_file.name: {
170-
__save_morph_as__: f"Morph_with_Target_{target_file.stem}.cgr"
175+
__save_morph_as__: (
176+
f"Morph_with_Target_{target_file.stem}.cgr"
177+
)
171178
}
172179
}
173180
)
174181
else:
175182
save_names.update(
176183
{
177184
target_file.name: {
178-
__save_morph_as__: f"Morph_of_{target_file.stem}.cgr"
185+
__save_morph_as__: (
186+
f"Morph_of_{target_file.stem}.cgr"
187+
)
179188
}
180189
}
181190
)
@@ -209,11 +218,14 @@ def multiple_morph_output(
209218
save_directory
210219
Name of directory to save morphs in.
211220
field
212-
Name of field if data was sorted by a particular field. Otherwise, leave blank.
221+
Name of field if data was sorted by a particular field.
222+
Otherwise, leave blank.
213223
field_list: list
214-
List of field values for each target PDF. Generated by diffpy.pdfmorph.tools.field_sort().
224+
List of field values for each target PDF.
225+
Generated by diffpy.pdfmorph.tools.field_sort().
215226
morph_file
216-
Name of the morphed PDF file. Required to give summary data after saving to a directory.
227+
Name of the morphed PDF file.
228+
Required to give summary data after saving to a directory.
217229
target_directory
218230
Name of the directory containing the target PDF files.
219231
Required to give summary data after saving to a directory.
@@ -222,8 +234,8 @@ def multiple_morph_output(
222234
stdout_flag: bool
223235
Print to terminal when True (default False).
224236
mm: bool
225-
Multiple morphs done with a single target rather than multiple targets for a single morphed file.
226-
Swaps morph and target in the code.
237+
Multiple morphs done with a single target rather than multiple
238+
targets for a single morphed file. Swaps morph and target in the code.
227239
"""
228240

229241
# Input parameters used for every morph
@@ -235,7 +247,8 @@ def multiple_morph_output(
235247
# Verbose to get output for every morph
236248
verbose_outputs = ""
237249
if verbose:
238-
# Output for every morph (information repeated in a succinct table below)
250+
# Output for every morph
251+
# (information repeated in a succinct table below)
239252
for target in morph_results.keys():
240253
if not mm:
241254
output = f"\n# Target: {target}\n"
@@ -307,24 +320,27 @@ def multiple_morph_output(
307320

308321

309322
def tabulate_results(multiple_morph_results):
310-
"""Helper function to make a data table summarizing details about the results of multiple morphs.
323+
"""Helper function to make a data table summarizing details about the
324+
results of multiple morphs.
311325
312326
Parameters
313327
----------
314328
multiple_morph_results
315-
A collection of Dictionaries. Each Dictionary summarizes the resultsof a single morph.
329+
A collection of Dictionaries. Each Dictionary summarizes the
330+
resultsof a single morph.
316331
317332
Returns
318333
-------
319334
tabulated_results: dict
320-
Keys in tabulated_results are the table's column names and each corresponding value is a list
321-
of data for that column.
335+
Keys in tabulated_results are the table's column names and each
336+
corresponding value is a list of data for that column.
322337
"""
323338

324339
# We only care about the following parameters in our data tables
325340
relevant_parameters = ["Scale", "Smear", "Stretch", "Pearson", "Rw"]
326341

327-
# Keys in this table represent column names and the value will be a list of column data
342+
# Keys in this table represent column names and the value will be a list
343+
# of column data
328344
tabulated_results = {}
329345
for param in relevant_parameters:
330346
tabulated_results.update(

0 commit comments

Comments
 (0)