Skip to content

Commit f659ac7

Browse files
authored
Merge pull request #104 from cadenmyers13/black
Edits made by running pre-commit
2 parents 3a59dd5 + a2eba1a commit f659ac7

File tree

15 files changed

+109
-83
lines changed

15 files changed

+109
-83
lines changed

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
[run]
2-
source =
2+
source =
33
src/diffpy/pdfmorph/
44
[report]
55
omit =

.flake8

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,12 @@
1+
[flake8]
2+
exclude =
3+
.git,
4+
__pycache__,
5+
build,
6+
dist,
7+
versioneer.py,
8+
labpdfproc/_version.py,
9+
doc/manual/source/conf.py
10+
max-line-length = 115
11+
# Ignore some style 'errors' produced while formatting by 'black'
12+
ignore = E203, W503

.github/workflows/docs.yml

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ jobs:
2525

2626
- name: install requirements
2727
run: >-
28-
conda install -n build -c conda-forge
28+
conda install -n build -c conda-forge
2929
--file requirements/build.txt
3030
--file requirements/run.txt
3131
--file requirements/docs.txt
@@ -42,4 +42,3 @@ jobs:
4242
with:
4343
github_token: ${{ secrets.GITHUB_TOKEN }}
4444
publish_dir: ./doc/manual/build/html
45-

.isort.cfg

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,4 @@
1+
[settings]
2+
line_length = 115
3+
multi_line_output = 3
4+
include_trailing_comma = True

.pre-commit-config.yaml

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,9 @@ repos:
66
hooks:
77
- id: check-yaml
88
- id: end-of-file-fixer
9+
exclude: '\.(rst|txt)$'
910
- id: trailing-whitespace
11+
exclude: '\.(rst|txt)$'
1012
- repo: https://github.com/ambv/black
1113
rev: 23.3.0
1214
hooks:

doc/manual/source/conf.py

Lines changed: 41 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -13,65 +13,68 @@
1313
import sys
1414
from pathlib import Path
1515

16-
sys.path.insert(0, str(Path('../../..').resolve()))
17-
sys.path.insert(0, str(Path('../../../src').resolve()))
16+
sys.path.insert(0, str(Path("../../..").resolve()))
17+
sys.path.insert(0, str(Path("../../../src").resolve()))
1818

1919

2020
# -- Project information -----------------------------------------------------
2121

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

2727
# The full version, including alpha/beta/rc tags
2828
from importlib.metadata import version
29+
2930
fullversion = version(project_full)
3031
# The short X.Y version.
31-
version = ''.join(fullversion.split('.post')[:1])
32+
version = "".join(fullversion.split(".post")[:1])
3233
# The full version, including alpha/beta/rc tags.
3334
release = fullversion
3435

3536
# Get current date for copyright
3637
import time
37-
today = time.strftime('%B %d, %Y', time.localtime())
38+
39+
today = time.strftime("%B %d, %Y", time.localtime())
3840
year = today.split()[-1]
39-
copyright = copyright.replace('%Y', year)
41+
copyright = copyright.replace("%Y", year)
4042

4143

4244
# -- General configuration ---------------------------------------------------
4345

4446
# Add any Sphinx extension module names here, as strings. They can be
4547
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
4648
# ones.
47-
extensions = ['sphinx.ext.autodoc',
48-
'sphinx.ext.napoleon',
49-
'sphinx.ext.todo',
50-
'sphinx.ext.viewcode',
51-
'sphinx.ext.intersphinx',
52-
'sphinx_rtd_theme',
53-
'm2r',
49+
extensions = [
50+
"sphinx.ext.autodoc",
51+
"sphinx.ext.napoleon",
52+
"sphinx.ext.todo",
53+
"sphinx.ext.viewcode",
54+
"sphinx.ext.intersphinx",
55+
"sphinx_rtd_theme",
56+
"m2r",
5457
]
5558
napoleon_google_docstring = False
5659
napoleon_use_param = False
5760
napoleon_use_ivar = False
5861

5962
# Add any paths that contain templates here, relative to this directory.
60-
templates_path = ['_templates']
63+
templates_path = ["_templates"]
6164

62-
from jinja2 import Template, Environment, FileSystemLoader
65+
from jinja2 import Environment, FileSystemLoader, Template
6366

64-
source_suffix = '.rst'
67+
source_suffix = ".rst"
6568

66-
master_doc = 'index'
69+
master_doc = "index"
6770

68-
language = 'en'
71+
language = "en"
6972
# List of patterns, relative to source directory, that match files and
7073
# directories to ignore when looking for source files.
7174
# This pattern also affects html_static_path and html_extra_path.
72-
exclude_patterns = ['Thumbs.db', '.DS_Store']
75+
exclude_patterns = ["Thumbs.db", ".DS_Store"]
7376

74-
pygments_style = 'sphinx'
77+
pygments_style = "sphinx"
7578

7679
todo_include_todos = True
7780

@@ -80,7 +83,8 @@
8083
# The theme to use for HTML and HTML Help pages. See the documentation for
8184
# a list of builtin themes.
8285
import sphinx_rtd_theme
83-
html_theme = 'sphinx_rtd_theme'
86+
87+
html_theme = "sphinx_rtd_theme"
8488
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
8589

8690
html_theme_options = {}
@@ -90,25 +94,29 @@
9094
# so a file named "default.css" will overwrite the builtin "default.css".
9195
html_static_path = []
9296

93-
htmlhelp_basename = 'PDFmorphdoc'
97+
htmlhelp_basename = "PDFmorphdoc"
9498

9599
latex_documents = [
96-
(master_doc, 'pdfmorph.tex', 'PDFmorph Documentation',
97-
'author', 'manual'),
100+
(master_doc, "pdfmorph.tex", "PDFmorph Documentation", "author", "manual"),
98101
]
99102

100-
man_pages = [
101-
(master_doc, 'pdfmorph', 'PDFmorph Documentation', [author], 1)
102-
]
103+
man_pages = [(master_doc, "pdfmorph", "PDFmorph Documentation", [author], 1)]
103104

104105
texinfo_documents = [
105-
(master_doc, 'PDFmorph', 'PDFmorph Documentation', author,
106-
'PDFmorph', 'One line description of project.', 'Miscellaneous'),
106+
(
107+
master_doc,
108+
"PDFmorph",
109+
"PDFmorph Documentation",
110+
author,
111+
"PDFmorph",
112+
"One line description of project.",
113+
"Miscellaneous",
114+
),
107115
]
108116

109117
epub_title = project
110118
epub_author = author
111119
epub_publisher = author
112120
epub_copyright = copyright
113121

114-
epub_exclude_files = ['search.html']
122+
epub_exclude_files = ["search.html"]

run_tests.py

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,15 +1,16 @@
11
#!/usr/bin/env python
22

33
import sys
4+
45
import pytest
56

6-
if __name__ == '__main__':
7+
if __name__ == "__main__":
78
# show output results from every test function
8-
args = ['-v']
9+
args = ["-v"]
910
# show the message output for skipped and expected failure tests
1011
if len(sys.argv) > 1:
1112
args.extend(sys.argv[1:])
12-
print('pytest arguments: {}'.format(args))
13+
print("pytest arguments: {}".format(args))
1314
# # compute coverage stats for xpdAcq
1415
# call pytest and exit with the return code from pytest so that
1516
# travis will fail correctly if tests fail

src/diffpy/pdfmorph/morphs/morphishape.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515

1616

1717
"""class MorphISphere -- apply inverse spherical shape function
18-
class MorphISpheroid -- apply inverse spheroidal shape function
18+
class MorphISpheroid -- apply inverse spheroidal shape function
1919
"""
2020

2121

src/diffpy/pdfmorph/pdfmorph_io.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,8 @@ def single_morph_output(
4848
morph_file
4949
Name of the morphed PDF file. Required when printing to a non-terminal file.
5050
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 y_morph_out is a List of gr values.
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.
5253
verbose: bool
5354
Print additional details about the morph when True (default False).
5455
stdout_flag: bool

src/diffpy/pdfmorph/pdfmorphapp.py

Lines changed: 36 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -64,8 +64,8 @@ def custom_error(self, msg):
6464
metavar="NAME",
6565
dest="slocation",
6666
help="""Save the manipulated PDF to a file named NAME. Use \'-\' for stdout.
67-
When --multiple is enabled, save each manipulated PDF as a file in a directory named NAME;
68-
you can specify names for each saved PDF file using --save-names-file.""",
67+
When --multiple is enabled, save each manipulated PDF as a file in a directory named NAME;
68+
you can specify names for each saved PDF file using --save-names-file.""",
6969
)
7070
parser.add_option(
7171
"-v",
@@ -87,31 +87,31 @@ def custom_error(self, msg):
8787
action="store_true",
8888
dest="addpearson",
8989
help="""Maximize agreement in the Pearson function as well as
90-
minimizing the residual.""",
90+
minimizing the residual.""",
9191
)
9292

9393
group = optparse.OptionGroup(
9494
parser,
9595
"Multiple Morphs",
9696
"""This program can morph a PDF against multiple targets in one command.
97-
See -s and Plot Options for how saving and plotting functionality changes when performing multiple morphs.""",
97+
See -s and Plot Options for how saving and plotting functionality changes when performing multiple morphs.""",
9898
)
9999
parser.add_option_group(group)
100100
group.add_option(
101101
"--multiple",
102102
dest="multiple",
103103
action="store_true",
104104
help=f"""Changes usage to \'{prog_short} [options] FILE DIRECTORY\'. FILE
105-
will be morphed with each file in DIRECTORY as target.
106-
Files in DIRECTORY are sorted by alphabetical order unless a field is
107-
specified by --sort-by.""",
105+
will be morphed with each file in DIRECTORY as target.
106+
Files in DIRECTORY are sorted by alphabetical order unless a field is
107+
specified by --sort-by.""",
108108
)
109109
group.add_option(
110110
"--sort-by",
111111
metavar="FIELD",
112112
dest="field",
113113
help="""Used with --multiple to sort files in DIRECTORY by FIELD from lowest to highest.
114-
FIELD must be included in the header of all the PDF files.""",
114+
FIELD must be included in the header of all the PDF files.""",
115115
)
116116
group.add_option(
117117
"--reverse",
@@ -124,39 +124,39 @@ def custom_error(self, msg):
124124
metavar="SERIALFILE",
125125
dest="serfile",
126126
help="""Look for FIELD in a serial file instead.
127-
Must specify name of serial file SERIALFILE.""",
127+
Must specify name of serial file SERIALFILE.""",
128128
)
129129
group.add_option(
130130
"--save-names-file",
131131
metavar="NAMESFILE",
132132
dest="snamesfile",
133133
help=f"""Used when both -s and --multiple are enabled.
134-
Specify names for each manipulated PDF when saving (see -s) using a serial file
135-
NAMESFILE. The format of NAMESFILE should be as follows: each target PDF
136-
is an entry in NAMESFILE. For each entry, there should be a key {__save_morph_as__}
137-
whose value specifies the name to save the manipulated PDF as.
134+
Specify names for each manipulated PDF when saving (see -s) using a serial file
135+
NAMESFILE. The format of NAMESFILE should be as follows: each target PDF
136+
is an entry in NAMESFILE. For each entry, there should be a key {__save_morph_as__}
137+
whose value specifies the name to save the manipulated PDF as.
138138
(See sample names files in the PDFmorph tutorial).""",
139139
)
140140
group.add_option(
141141
"--plot-parameter",
142142
metavar="PLOTPARAM",
143143
dest="plotparam",
144144
help="""Used when both plotting and --multiple are enabled.
145-
Choose a PLOTPARAM to plot for each morph (i.e. adding --pp=Pearson means the program
146-
will display a plot of the Pearson correlation coefficient for each morph-target pair).
147-
PLOTPARAM is not case sensitive, so both Pearson and pearson indicate the same parameter.
148-
When PLOTPARAM is not specified, Rw values for each morph-target pair will be plotted.
149-
PLOTPARAM will be displayed as the vertical axis label for the plot.""",
145+
Choose a PLOTPARAM to plot for each morph (i.e. adding --pp=Pearson means the program
146+
will display a plot of the Pearson correlation coefficient for each morph-target pair).
147+
PLOTPARAM is not case sensitive, so both Pearson and pearson indicate the same parameter.
148+
When PLOTPARAM is not specified, Rw values for each morph-target pair will be plotted.
149+
PLOTPARAM will be displayed as the vertical axis label for the plot.""",
150150
)
151151

152152
# Manipulations
153153
group = optparse.OptionGroup(
154154
parser,
155155
"Manipulations",
156156
"""These options select the manipulations that are to be applied to
157-
the PDF from FILE1. The passed values will be refined unless specifically
158-
excluded with the -a or -x options. If no option is specified, the PDFs from FILE1 and FILE2 will
159-
be plotted without any manipulations.""",
157+
the PDF from FILE1. The passed values will be refined unless specifically
158+
excluded with the -a or -x options. If no option is specified, the PDFs from FILE1 and FILE2 will
159+
be plotted without any manipulations.""",
160160
)
161161
parser.add_option_group(group)
162162
group.add_option(
@@ -173,7 +173,7 @@ def custom_error(self, msg):
173173
dest="exclude",
174174
metavar="MANIP",
175175
help="""Exclude a manipulation from refinement by name. This can
176-
appear multiple times.""",
176+
appear multiple times.""",
177177
)
178178
group.add_option("--scale", type="float", metavar="SCALE", help="Apply scale factor SCALE.")
179179
group.add_option(
@@ -193,7 +193,7 @@ def custom_error(self, msg):
193193
type="float",
194194
dest="baselineslope",
195195
help="""Slope of the baseline. This is used when applying the smear
196-
factor. It will be estimated if not provided.""",
196+
factor. It will be estimated if not provided.""",
197197
)
198198
group.add_option(
199199
"--qdamp",
@@ -206,36 +206,42 @@ def custom_error(self, msg):
206206
type="float",
207207
metavar="RADIUS",
208208
help="""Apply characteristic function of sphere with radius RADIUS.
209-
If PRADIUS is also specified, instead apply characteristic function of spheroid with equatorial radius RADIUS and polar radius PRADIUS.""",
209+
If PRADIUS is also specified, instead apply characteristic function of spheroid with equatorial
210+
radius RADIUS and polar radius PRADIUS.""",
210211
)
211212
group.add_option(
212213
"--pradius",
213214
type="float",
214215
metavar="PRADIUS",
215216
help="""Apply characteristic function of spheroid with equatorial
216-
radius RADIUS and polar radius PRADIUS. If only PRADIUS is specified, instead apply characteristic function of sphere with radius PRADIUS.""",
217+
radius RADIUS and polar radius PRADIUS. If only PRADIUS is specified, instead apply
218+
characteristic function of sphere with radius PRADIUS.""",
217219
)
218220
group.add_option(
219221
"--iradius",
220222
type="float",
221223
metavar="IRADIUS",
222-
help="""Apply inverse characteristic function of sphere with radius IRADIUS. If IPRADIUS is also specified, instead apply inverse characteristic function of spheroid with equatorial radius IRADIUS and polar radius IPRADIUS.""",
224+
help="""Apply inverse characteristic function of sphere with radius IRADIUS.
225+
If IPRADIUS is also specified, instead apply inverse characteristic function of spheroid
226+
with equatorial radius IRADIUS and polar radius IPRADIUS.""",
223227
)
224228
group.add_option(
225229
"--ipradius",
226230
type="float",
227231
metavar="IPRADIUS",
228-
help="""Apply inverse characteristic function of spheroid with equatorial radius IRADIUS and polar radius IPRADIUS. If only IPRADIUS is specified, instead apply inverse characteristic function of sphere with radius IPRADIUS.""",
232+
help="""Apply inverse characteristic function of spheroid with equatorial radius IRADIUS
233+
and polar radius IPRADIUS. If only IPRADIUS is specified, instead apply inverse characteristic
234+
function of sphere with radius IPRADIUS.""",
229235
)
230236

231237
# Plot Options
232238
group = optparse.OptionGroup(
233239
parser,
234240
"Plot Options",
235241
"""These options control plotting.
236-
The manipulated and target PDFs will be plotted against each other with a
237-
difference curve below. When --multiple is enabled, the value of a parameter (specified by
238-
--plot-parameter) will be plotted instead.""",
242+
The manipulated and target PDFs will be plotted against each other with a
243+
difference curve below. When --multiple is enabled, the value of a parameter (specified by
244+
--plot-parameter) will be plotted instead.""",
239245
)
240246
parser.add_option_group(group)
241247
group.add_option(

0 commit comments

Comments
 (0)