Skip to content

Commit 471c795

Browse files
authored
Merge pull request #35 from dabeycorn/black-edits
skpkg: apply black line-length 115 to all files in the project directory
2 parents a731051 + 1eb4bd6 commit 471c795

File tree

8 files changed

+116
-40
lines changed

8 files changed

+116
-40
lines changed

.github/ISSUE_TEMPLATE/release_checklist.md

Lines changed: 21 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -6,30 +6,41 @@ labels: "release"
66
assignees: ""
77
---
88

9-
### PyPI/GitHub release checklist:
9+
### PyPI/GitHub rc-release preparation checklist:
1010

1111
- [ ] All PRs/issues attached to the release are merged.
1212
- [ ] All the badges on the README are passing.
1313
- [ ] License information is verified as correct. If you are unsure, please comment below.
1414
- [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are
15-
missing), tutorials, and other human written text is up-to-date with any changes in the code.
16-
- [ ] Installation instructions in the README, documentation and on the website (e.g., diffpy.org) are updated.
15+
missing), tutorials, and other human-written text is up-to-date with any changes in the code.
16+
- [ ] Installation instructions in the README, documentation, and the website are updated.
1717
- [ ] Successfully run any tutorial examples or do functional testing with the latest Python version.
1818
- [ ] Grammar and writing quality are checked (no typos).
19+
- [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release.
1920

20-
Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as
21-
version information and details about the pre-release here:
21+
Please tag the maintainer (e.g., @username) in the comment here when you are ready for the PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here:
2222

23-
### conda-forge release checklist:
23+
### PyPI/GitHub full-release preparation checklist:
2424

25-
<!-- After @sbillinge releases the PyPI package, please check the following when creating a PR for conda-forge release.-->
25+
- [ ] Create a new conda environment and install the rc from PyPI (`pip install <package-name>==??`)
26+
- [ ] License information on PyPI is correct.
27+
- [ ] Docs are deployed successfully to `https://<github-username-or-orgname>/<package-name>`.
28+
- [ ] Successfully run all tests, tutorial examples or do functional testing.
2629

30+
Please let the maintainer know that all checks are done and the package is ready for full release.
31+
32+
### conda-forge release preparation checklist:
33+
34+
<!-- After the maintainer releases the PyPI package, please check the following when creating a PR for conda-forge release.-->
35+
36+
- [ ] Ensure that the full release has appeared on PyPI successfully.
2737
- [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock.
28-
- [ ] All relevant issues in the feedstock are addressed in the release PR.
38+
- [ ] Close any open issues on the feedstock. Reach out to the maintainer if you have questions.
39+
- [ ] Tag the maintainer for conda-forge release.
2940

3041
### Post-release checklist
3142

3243
<!-- Before closing this issue, please complete the following: -->
3344

34-
- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
35-
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.
45+
- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments.
46+
- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures.

doc/source/conf.py

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -221,7 +221,13 @@
221221
# (source start file, target name, title,
222222
# author, documentclass [howto, manual, or own class]).
223223
latex_documents = [
224-
("index", "diffpy.nmf_mapping.tex", "diffpy.nmf_mapping Documentation", ab_authors, "manual"),
224+
(
225+
"index",
226+
"diffpy.nmf_mapping.tex",
227+
"diffpy.nmf_mapping Documentation",
228+
ab_authors,
229+
"manual",
230+
),
225231
]
226232

227233
# The name of an image file (relative to this directory) to place at the top of
@@ -249,7 +255,15 @@
249255

250256
# One entry per manual page. List of tuples
251257
# (source start file, name, description, authors, manual section).
252-
man_pages = [("index", "diffpy.nmf_mapping", "diffpy.nmf_mapping Documentation", ab_authors, 1)]
258+
man_pages = [
259+
(
260+
"index",
261+
"diffpy.nmf_mapping",
262+
"diffpy.nmf_mapping Documentation",
263+
ab_authors,
264+
1,
265+
)
266+
]
253267

254268
# If true, show URL addresses after external links.
255269
# man_show_urls = False

src/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#
1414
##############################################################################
1515

16-
"""nmf_mapping - tools for performing NMF on PDF and XRD data.
17-
"""
16+
"""nmf_mapping - tools for performing NMF on PDF and XRD data."""
1817

1918

2019
__import__("pkg_resources").declare_namespace(__name__)

src/diffpy/nmf_mapping/main.py

Lines changed: 48 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,11 @@ def main(args=None):
3131
as well as the reconstruction error as a fxn of component
3232
"""
3333

34-
parser = ArgumentParser(prog="nmf_mapping", description=_BANNER, formatter_class=RawTextHelpFormatter)
34+
parser = ArgumentParser(
35+
prog="nmf_mapping",
36+
description=_BANNER,
37+
formatter_class=RawTextHelpFormatter,
38+
)
3539

3640
def tup(s):
3741
if not isinstance(s, str):
@@ -45,7 +49,10 @@ def tup(s):
4549

4650
# args
4751
parser.add_argument(
48-
"directory", default=None, type=str, help="a directory of PDFs to calculate NMF decomposition"
52+
"directory",
53+
default=None,
54+
type=str,
55+
help="a directory of PDFs to calculate NMF decomposition",
4956
)
5057
group = parser.add_mutually_exclusive_group()
5158
parser.add_argument(
@@ -105,25 +112,37 @@ def tup(s):
105112
nargs="*",
106113
help="the x-range over which to calculate NMF, can be multiple ranges (e.g. --xrange 5,10 12,15)",
107114
)
108-
parser.add_argument("--show", default=True, type=boolean_string, help="whether to show the plot")
115+
parser.add_argument(
116+
"--show",
117+
default=True,
118+
type=boolean_string,
119+
help="whether to show the plot",
120+
)
109121
args0 = Namespace()
110122
args1, _ = parser.parse_known_args(args, namespace=args0)
111123

112124
input_list, data_list = nmf.load_data(args1.directory, args1.xrd)
113125
if args1.pca_thresh:
114-
df_components, df_component_weight_timeseries, df_reconstruction_error, df_explained_var_ratio = (
115-
nmf.NMF_decomposition(
116-
input_list,
117-
args1.xrange,
118-
args1.threshold,
119-
additional_comp=False,
120-
improve_thresh=args1.improve_thresh,
121-
n_iter=args1.n_iter,
122-
pca_thresh=args1.pca_thresh,
123-
)
126+
(
127+
df_components,
128+
df_component_weight_timeseries,
129+
df_reconstruction_error,
130+
df_explained_var_ratio,
131+
) = nmf.NMF_decomposition(
132+
input_list,
133+
args1.xrange,
134+
args1.threshold,
135+
additional_comp=False,
136+
improve_thresh=args1.improve_thresh,
137+
n_iter=args1.n_iter,
138+
pca_thresh=args1.pca_thresh,
124139
)
125140
else:
126-
df_components, df_component_weight_timeseries, df_reconstruction_error = nmf.NMF_decomposition(
141+
(
142+
df_components,
143+
df_component_weight_timeseries,
144+
df_reconstruction_error,
145+
) = nmf.NMF_decomposition(
127146
input_list,
128147
args1.xrange,
129148
args1.threshold,
@@ -149,7 +168,11 @@ def tup(s):
149168
os.path.join(os.getcwd(), "nmf_result", "component_index_vs_pratio_col.json")
150169
)
151170
df_component_weight_timeseries.to_csv(
152-
os.path.join(os.getcwd(), "nmf_result", output_fn + "component_row_pratio_col.txt"),
171+
os.path.join(
172+
os.getcwd(),
173+
"nmf_result",
174+
output_fn + "component_row_pratio_col.txt",
175+
),
153176
header=None,
154177
index=False,
155178
sep=" ",
@@ -196,7 +219,11 @@ def tup(s):
196219

197220
if args1.xrd:
198221
np.savetxt(
199-
os.path.join(os.getcwd(), "nmf_result", output_fn + f"_comp{i}" + ".xy"),
222+
os.path.join(
223+
os.getcwd(),
224+
"nmf_result",
225+
output_fn + f"_comp{i}" + ".xy",
226+
),
200227
data,
201228
header=f"NMF Generated XRD\nSource = nmfMapping\n"
202229
f"Date = {output_fn}\n{args1.x_units} Intensity\n",
@@ -205,7 +232,11 @@ def tup(s):
205232
)
206233
else:
207234
np.savetxt(
208-
os.path.join(os.getcwd(), "nmf_result", output_fn + f"_comp{i}" + ".cgr"),
235+
os.path.join(
236+
os.getcwd(),
237+
"nmf_result",
238+
output_fn + f"_comp{i}" + ".cgr",
239+
),
209240
data,
210241
header=f"NMF Generated PDF\nSource: nmfMapping\n" f"Date: {output_fn}\nr g",
211242
fmt="%s",

src/diffpy/nmf_mapping/nmf_mapping_code.py

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -98,7 +98,13 @@ def load_data(dir, xrd=False):
9898

9999
# TODO Add regularization on the frobenius norm in order to prevent creation of an excessive number of components
100100
def NMF_decomposition(
101-
data_arr, x_range=None, thresh=None, additional_comp=False, improve_thresh=None, n_iter=None, pca_thresh=None
101+
data_arr,
102+
x_range=None,
103+
thresh=None,
104+
additional_comp=False,
105+
improve_thresh=None,
106+
n_iter=None,
107+
pca_thresh=None,
102108
):
103109
"""
104110
Takes a 3D array of PDFs and returns the structurally significant
@@ -208,8 +214,17 @@ def NMF_decomposition(
208214
df_component_weight_timeseries = pd.DataFrame(nmf_weight, index=range(n_comp))
209215

210216
if pca_thresh:
211-
return df_components, df_component_weight_timeseries, df_reconstruction_error, df_explained_var_ratio
212-
return df_components, df_component_weight_timeseries, df_reconstruction_error
217+
return (
218+
df_components,
219+
df_component_weight_timeseries,
220+
df_reconstruction_error,
221+
df_explained_var_ratio,
222+
)
223+
return (
224+
df_components,
225+
df_component_weight_timeseries,
226+
df_reconstruction_error,
227+
)
213228

214229

215230
def component_plot(df_components, xrd=False, x_units=None, show=True):
@@ -244,7 +259,11 @@ def component_plot(df_components, xrd=False, x_units=None, show=True):
244259
shift = max_range
245260
# seq to align with input phase
246261
for i, s in enumerate(data_list):
247-
ax.plot(df.index.to_numpy(dtype=np.single), df[s].to_numpy() + i * shift, label=s)
262+
ax.plot(
263+
df.index.to_numpy(dtype=np.single),
264+
df[s].to_numpy() + i * shift,
265+
label=s,
266+
)
248267
ax.legend(loc="best")
249268
if xrd:
250269
if x_units == "twotheta" or x_units == "ttheta":

src/diffpy/version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,7 @@
1313
#
1414
##############################################################################
1515

16-
"""Definition of __version__ and __date__ for diffpy.nmf_mapping.
17-
"""
16+
"""Definition of __version__ and __date__ for diffpy.nmf_mapping."""
1817

1918
__id__ = "$Id$"
2019

tests/test_NMF_analysis_code.py

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,11 @@
1414
test_map = [
1515
([data_dir, "--xrange", "5,10"], "output_1", "Number of components: 3\n"),
1616
([data_dir], "output_2", "Number of components: 3\n"),
17-
([data_dir, "--xrange", "5,10", "12,15"], "output_3", "Number of components: 3\n"),
17+
(
18+
[data_dir, "--xrange", "5,10", "12,15"],
19+
"output_3",
20+
"Number of components: 3\n",
21+
),
1822
]
1923

2024

tests/test_version.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
1-
"""Unit tests for __version__.py
2-
"""
1+
"""Unit tests for __version__.py"""
32

43
import diffpy.nmf_mapping
54

0 commit comments

Comments
 (0)