Skip to content

Commit 576afb2

Browse files
committed
No manual edits made to reformat docstrings
1 parent 8107874 commit 576afb2

File tree

13 files changed

+47
-61
lines changed

13 files changed

+47
-61
lines changed

.pre-commit-config.yaml

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,3 +58,10 @@ repos:
5858
- id: prettier
5959
additional_dependencies:
6060
- "prettier@^3.2.4"
61+
# docformatter - formats docstrings using PEP 257
62+
- repo: https://github.com/s-weigand/docformatter
63+
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
64+
hooks:
65+
- id: docformatter
66+
additional_dependencies: [tomli]
67+
args: [--in-place, --config, ./pyproject.toml]

src/diffpy/__init__.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,6 @@
1616
# See LICENSE.rst for license information.
1717
#
1818
##############################################################################
19-
2019
"""diffpy - tools for structure analysis by diffraction.
2120
2221
Blank namespace package.

src/diffpy/utils/__init__.py

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,7 @@
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
16-
"""Shared utilities for diffpy packages"""
15+
"""Shared utilities for diffpy packages."""
1716

1817
# package version
1918
from diffpy.utils.version import __version__

src/diffpy/utils/parsers/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""Various utilities related to data parsing and manipulation.
17-
"""
15+
"""Various utilities related to data parsing and manipulation."""

src/diffpy/utils/parsers/serialization.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -33,8 +33,8 @@ def serialize_data(
3333
show_path=True,
3434
serial_file=None,
3535
):
36-
"""Serialize file data into a dictionary. Can also save dictionary into a serial language file. Dictionary is
37-
formatted as {filename: data}.
36+
"""Serialize file data into a dictionary. Can also save dictionary into a
37+
serial language file. Dictionary is formatted as {filename: data}.
3838
3939
Requires hdata and data_table (can be generated by loadData).
4040

src/diffpy/utils/resampler.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
1615
"""Various utilities related to data parsing and manipulation."""
1716

1817
import warnings
@@ -80,7 +79,8 @@ def wsinterp(x, xp, fp, left=None, right=None):
8079

8180

8281
def nsinterp(xp, fp, qmin=0, qmax=25, left=None, right=None):
83-
"""One-dimensional Whittaker-Shannon interpolation onto the Nyquist-Shannon grid.
82+
"""One-dimensional Whittaker-Shannon interpolation onto the Nyquist-Shannon
83+
grid.
8484
8585
Takes a band-limited function fp and original grid xp and resamples fp on the NS grid.
8686
Uses the minimum number of points N required by the Nyquist sampling theorem.

src/diffpy/utils/tools.py

Lines changed: 6 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -5,8 +5,7 @@
55

66

77
def clean_dict(obj):
8-
"""
9-
Remove keys from the dictionary where the corresponding value is None.
8+
"""Remove keys from the dictionary where the corresponding value is None.
109
1110
Parameters
1211
----------
@@ -17,7 +16,6 @@ def clean_dict(obj):
1716
-------
1817
dict:
1918
The cleaned dictionary with keys removed where the value is None.
20-
2119
"""
2220
obj = obj if obj is not None else {}
2321
for key, value in copy(obj).items():
@@ -27,8 +25,7 @@ def clean_dict(obj):
2725

2826

2927
def stringify(obj):
30-
"""
31-
Convert None to an empty string.
28+
"""Convert None to an empty string.
3229
3330
Parameters
3431
----------
@@ -44,8 +41,7 @@ def stringify(obj):
4441

4542

4643
def load_config(file_path):
47-
"""
48-
Load configuration from a .json file.
44+
"""Load configuration from a .json file.
4945
5046
Parameters
5147
----------
@@ -56,7 +52,6 @@ def load_config(file_path):
5652
-------
5753
dict:
5854
The configuration dictionary or {} if the config file does not exist.
59-
6055
"""
6156
config_file = Path(file_path).resolve()
6257
if config_file.is_file():
@@ -91,8 +86,8 @@ def _create_global_config(args):
9186

9287

9388
def get_user_info(owner_name=None, owner_email=None, owner_orcid=None):
94-
"""
95-
Get name, email and orcid of the owner/user from various sources and return it as a metadata dictionary
89+
"""Get name, email and orcid of the owner/user from various sources and
90+
return it as a metadata dictionary.
9691
9792
The function looks for the information in json format configuration files with the name 'diffpyconfig.json'.
9893
These can be in the user's home directory and in the current working directory. The information in the
@@ -124,7 +119,6 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None):
124119
dict:
125120
The dictionary containing username, email and orcid of the user/owner, and any other information
126121
stored in the global or local config files.
127-
128122
"""
129123
runtime_info = {"owner_name": owner_name, "owner_email": owner_email, "owner_orcid": owner_orcid}
130124
for key, value in copy(runtime_info).items():
@@ -149,8 +143,7 @@ def get_user_info(owner_name=None, owner_email=None, owner_orcid=None):
149143

150144

151145
def get_package_info(package_names, metadata=None):
152-
"""
153-
Fetches package version and updates it into (given) metadata.
146+
"""Fetches package version and updates it into (given) metadata.
154147
155148
Package info stored in metadata as {'package_info': {'package_name': 'version_number'}}.
156149
@@ -164,7 +157,6 @@ def get_package_info(package_names, metadata=None):
164157
-------
165158
dict:
166159
The updated metadata dict with package info inserted.
167-
168160
"""
169161
if metadata is None:
170162
metadata = {}

src/diffpy/utils/transforms.py

Lines changed: 7 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,7 @@ def _validate_inputs(q, wavelength):
2929

3030

3131
def q_to_tth(q, wavelength):
32-
r"""
33-
Helper function to convert q to two-theta.
32+
r"""Helper function to convert q to two-theta.
3433
3534
If wavelength is missing, returns x-values that are integer indexes
3635
@@ -72,9 +71,7 @@ def q_to_tth(q, wavelength):
7271

7372

7473
def tth_to_q(tth, wavelength):
75-
r"""
76-
77-
Helper function to convert two-theta to q on independent variable axis.
74+
r"""Helper function to convert two-theta to q on independent variable axis.
7875
7976
If wavelength is missing, returns independent variable axis as integer indexes.
8077
@@ -120,8 +117,8 @@ def tth_to_q(tth, wavelength):
120117

121118

122119
def q_to_d(q):
123-
r"""
124-
Helper function to convert q to d on independent variable axis, using :math:`d = \frac{2 \pi}{q}`.
120+
r"""Helper function to convert q to d on independent variable axis, using
121+
:math:`d = \frac{2 \pi}{q}`.
125122
126123
Parameters
127124
----------
@@ -140,8 +137,7 @@ def q_to_d(q):
140137

141138

142139
def tth_to_d(tth, wavelength):
143-
r"""
144-
Helper function to convert two-theta to d on independent variable axis.
140+
r"""Helper function to convert two-theta to d on independent variable axis.
145141
146142
The formula is .. math:: d = \frac{\lambda}{2 \sin\left(\frac{2\theta}{2}\right)}.
147143
@@ -174,8 +170,7 @@ def tth_to_d(tth, wavelength):
174170

175171

176172
def d_to_q(d):
177-
r"""
178-
Helper function to convert q to d using :math:`d = \frac{2 \pi}{q}`.
173+
r"""Helper function to convert q to d using :math:`d = \frac{2 \pi}{q}`.
179174
180175
Parameters
181176
----------
@@ -194,8 +189,7 @@ def d_to_q(d):
194189

195190

196191
def d_to_tth(d, wavelength):
197-
r"""
198-
Helper function to convert d to two-theta on independent variable axis.
192+
r"""Helper function to convert d to two-theta on independent variable axis.
199193
200194
The formula is .. math:: 2\theta = 2 \arcsin\left(\frac{\lambda}{2d}\right).
201195

src/diffpy/utils/version.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
1615
"""Definition of __version__."""
1716

1817
# We do not use the other three variables, but can be added back if needed.

src/diffpy/utils/wx/__init__.py

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,4 @@
1212
# See LICENSE_DANSE.txt for license information.
1313
#
1414
##############################################################################
15-
16-
"""Utilities related wx Python GUIs.
17-
"""
15+
"""Utilities related wx Python GUIs."""

0 commit comments

Comments
 (0)