Skip to content

Commit 6526430

Browse files
authored
Merge pull request #164 from ycexiao/line_width
style: set the line width limit to 79
2 parents fa1dd17 + 116fe95 commit 6526430

34 files changed

+835
-314
lines changed

.flake8

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ exclude =
55
build,
66
dist,
77
doc/source/conf.py
8-
max-line-length = 115
8+
max-line-length = 79
99
# Ignore some style 'errors' produced while formatting by 'black'
1010
# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings
1111
extend-ignore = E203

.isort.cfg

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
[settings]
2-
line_length = 115
2+
line_length = 79
33
multi_line_output = 3
44
include_trailing_comma = True

doc/source/conf.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -223,7 +223,13 @@
223223
# (source start file, target name, title,
224224
# author, documentclass [howto, manual, or own class]).
225225
latex_documents = [
226-
("index", "diffpy.pdfmorph.tex", "diffpy.pdfmorph Documentation", ab_authors, "manual"),
226+
(
227+
"index",
228+
"diffpy.pdfmorph.tex",
229+
"diffpy.pdfmorph Documentation",
230+
ab_authors,
231+
"manual",
232+
),
227233
]
228234

229235
# The name of an image file (relative to this directory) to place at the top of
@@ -251,7 +257,15 @@
251257

252258
# One entry per manual page. List of tuples
253259
# (source start file, name, description, authors, manual section).
254-
man_pages = [("index", "diffpy.pdfmorph", "diffpy.pdfmorph Documentation", ab_authors, 1)]
260+
man_pages = [
261+
(
262+
"index",
263+
"diffpy.pdfmorph",
264+
"diffpy.pdfmorph Documentation",
265+
ab_authors,
266+
1,
267+
)
268+
]
255269

256270
# If true, show URL addresses after external links.
257271
# man_show_urls = False

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+
* <news item>
8+
9+
**Deprecated:**
10+
11+
* <news item>
12+
13+
**Removed:**
14+
15+
* <news item>
16+
17+
**Fixed:**
18+
19+
* reduce the line width limit to 79
20+
21+
**Security:**
22+
23+
* <news item>

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,7 +60,7 @@ ignore-words = ".codespell/ignore_words.txt"
6060
skip = "*.cif,*.dat,*agr"
6161

6262
[tool.black]
63-
line-length = 115
63+
line-length = 79
6464
include = '\.pyi?$'
6565
exclude = '''
6666
/(

src/diffpy/pdfmorph/morph_helpers/__init__.py

Lines changed: 8 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,10 +11,15 @@
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

16-
from diffpy.pdfmorph.morph_helpers.transformpdftordf import TransformXtalPDFtoRDF
17-
from diffpy.pdfmorph.morph_helpers.transformrdftopdf import TransformXtalRDFtoPDF
17+
from diffpy.pdfmorph.morph_helpers.transformpdftordf import (
18+
TransformXtalPDFtoRDF,
19+
)
20+
from diffpy.pdfmorph.morph_helpers.transformrdftopdf import (
21+
TransformXtalRDFtoPDF,
22+
)
1823

1924
# List of helpers
2025
morph_helpers = [

src/diffpy/pdfmorph/morph_helpers/transformpdftordf.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,9 @@ def morph(self, x_morph, y_morph, x_target, y_target):
5151
morph_baseline = self.baselineslope * self.x_morph_in
5252
self.y_morph_out = self.x_morph_in * (self.y_morph_in - morph_baseline)
5353
target_baseline = self.baselineslope * self.x_target_in
54-
self.y_target_out = self.x_target_in * (self.y_target_in - target_baseline)
54+
self.y_target_out = self.x_target_in * (
55+
self.y_target_in - target_baseline
56+
)
5557
return self.xyallout
5658

5759

src/diffpy/pdfmorph/morph_helpers/transformrdftopdf.py

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -53,10 +53,14 @@ def morph(self, x_morph, y_morph, x_target, y_target):
5353
morph_baseline = self.baselineslope * self.x_morph_in
5454
target_baseline = self.baselineslope * self.x_target_in
5555
with numpy.errstate(divide="ignore", invalid="ignore"):
56-
self.y_target_out = self.y_target_in / self.x_target_in + target_baseline
56+
self.y_target_out = (
57+
self.y_target_in / self.x_target_in + target_baseline
58+
)
5759
self.y_target_out[self.x_target_in == 0] = 0
5860
with numpy.errstate(divide="ignore", invalid="ignore"):
59-
self.y_morph_out = self.y_morph_in / self.x_morph_in + morph_baseline
61+
self.y_morph_out = (
62+
self.y_morph_in / self.x_morph_in + morph_baseline
63+
)
6064
self.y_morph_out[self.x_target_in == 0] = 0
6165
return self.xyallout
6266

src/diffpy/pdfmorph/morphs/morph.py

Lines changed: 14 additions & 7 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
-------
@@ -234,7 +239,9 @@ def plotOutputs(self, xylabels=True, **plotargs):
234239

235240
pargs = dict(plotargs)
236241
pargs.pop("label", None)
237-
rv = plot(self.x_target_out, self.y_target_out, label="target", **pargs)
242+
rv = plot(
243+
self.x_target_out, self.y_target_out, label="target", **pargs
244+
)
238245
rv = plot(self.x_morph_out, self.y_morph_out, label="morph", **pargs)
239246
if xylabels:
240247
xlabel(self.xoutlabel)

src/diffpy/pdfmorph/morphs/morphchain.py

Lines changed: 50 additions & 18 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
@@ -66,19 +68,47 @@ class MorphChain(list):
6668
The properties return tuples of None if there are no morphs.
6769
"""
6870

69-
x_morph_in = property(lambda self: None if len(self) == 0 else self[0].x_morph_in)
70-
y_morph_in = property(lambda self: None if len(self) == 0 else self[0].y_morph_in)
71-
x_target_in = property(lambda self: None if len(self) == 0 else self[0].x_target_in)
72-
y_target_in = property(lambda self: None if len(self) == 0 else self[0].y_target_in)
73-
x_morph_out = property(lambda self: None if len(self) == 0 else self[-1].x_morph_out)
74-
y_morph_out = property(lambda self: None if len(self) == 0 else self[-1].y_morph_out)
75-
x_target_out = property(lambda self: None if len(self) == 0 else self[-1].x_target_out)
76-
y_target_out = property(lambda self: None if len(self) == 0 else self[-1].y_target_out)
77-
xy_morph_in = property(lambda self: (None, None) if len(self) == 0 else self[0].xy_morph_in)
78-
xy_morph_out = property(lambda self: (None, None) if len(self) == 0 else self[-1].xy_morph_out)
79-
xy_target_in = property(lambda self: (None, None) if len(self) == 0 else self[0].xy_target_in)
80-
xy_target_out = property(lambda self: (None, None) if len(self) == 0 else self[-1].xy_target_out)
81-
xyallout = property(lambda self: (None, None, None, None) if len(self) == 0 else self[-1].xyallout)
71+
x_morph_in = property(
72+
lambda self: None if len(self) == 0 else self[0].x_morph_in
73+
)
74+
y_morph_in = property(
75+
lambda self: None if len(self) == 0 else self[0].y_morph_in
76+
)
77+
x_target_in = property(
78+
lambda self: None if len(self) == 0 else self[0].x_target_in
79+
)
80+
y_target_in = property(
81+
lambda self: None if len(self) == 0 else self[0].y_target_in
82+
)
83+
x_morph_out = property(
84+
lambda self: None if len(self) == 0 else self[-1].x_morph_out
85+
)
86+
y_morph_out = property(
87+
lambda self: None if len(self) == 0 else self[-1].y_morph_out
88+
)
89+
x_target_out = property(
90+
lambda self: None if len(self) == 0 else self[-1].x_target_out
91+
)
92+
y_target_out = property(
93+
lambda self: None if len(self) == 0 else self[-1].y_target_out
94+
)
95+
xy_morph_in = property(
96+
lambda self: (None, None) if len(self) == 0 else self[0].xy_morph_in
97+
)
98+
xy_morph_out = property(
99+
lambda self: (None, None) if len(self) == 0 else self[-1].xy_morph_out
100+
)
101+
xy_target_in = property(
102+
lambda self: (None, None) if len(self) == 0 else self[0].xy_target_in
103+
)
104+
xy_target_out = property(
105+
lambda self: (None, None) if len(self) == 0 else self[-1].xy_target_out
106+
)
107+
xyallout = property(
108+
lambda self: (
109+
(None, None, None, None) if len(self) == 0 else self[-1].xyallout
110+
)
111+
)
82112
parnames = property(lambda self: set(p for m in self for p in m.parnames))
83113

84114
def __init__(self, config, *args):
@@ -89,7 +119,8 @@ def __init__(self, config, *args):
89119
90120
Notes
91121
-----
92-
Additional arguments are morphs that will extend the queue of morphs.
122+
Additional arguments are morphs that will extend the queue of
123+
morphs.
93124
"""
94125
self.config = config
95126
self.extend(args)
@@ -108,7 +139,8 @@ def morph(self, x_morph, y_morph, x_target, y_target):
108139
Returns
109140
-------
110141
tuple
111-
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).
112144
113145
Notes
114146
-----

0 commit comments

Comments
 (0)