Skip to content

Commit 83ad2ec

Browse files
authored
Merge pull request diffpy#190 from yucongalicechen/recut
recut using ``scikit-package`` to allow docs preview
2 parents 78d0677 + 924615e commit 83ad2ec

16 files changed

+125
-72
lines changed

.codespell/ignore_words.txt

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,5 @@
44
;; abbreviation for "materials" often used in a journal title
55
mater
66

7-
;; alternative use of socioeconomic
8-
socio-economic
9-
107
;; Frobenius norm used in np.linalg.norm
118
fro
Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,15 @@
1+
### What problem does this PR address?
2+
3+
<!-- Provide a brief overview and link to the issue. Attach outputs, including screenshots (before/after), if helpful for the reviewer. -->
4+
5+
### What should the reviewer(s) do?
6+
7+
<!-- Merge the code, provide feedback, initiate a discussion, etc. -->
8+
9+
<!--
10+
Use the following checklist items when applicable (select only what applies):
11+
- [ ] This PR introduces a public-facing change (e.g., figures, CLI input/output, API).
12+
- [ ] Documentation (e.g., tutorials, examples, README) has been updated.
13+
- [ ] A tracking issue or plan to update documentation exists.
14+
- [ ] This PR affects internal functionality only (no user-facing change).
15+
-->

.github/workflows/build-wheel-release-upload.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ on:
44
workflow_dispatch:
55
push:
66
tags:
7-
- '*' # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml
7+
- "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml
88

99
jobs:
1010
release:

.github/workflows/check-news-item.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ name: Check for News
33
on:
44
pull_request_target:
55
branches:
6-
- main
6+
- main
77

88
jobs:
99
check-news-item:

.github/workflows/matrix-and-codecov-on-merge-to-main.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ jobs:
2323
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
2424
python-version: ["3.11", "3.12", "3.13"]
2525
env:
26-
LATEST_PYTHON_VERSION: "3.13"
26+
LATEST_PYTHON_VERSION: "3.13"
2727
steps:
2828
- name: Check out diffpy.labpdfproc
2929
uses: actions/checkout@v4

.github/workflows/tests-on-pr.yml

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,6 @@ jobs:
3939
pip install gooey
4040
python -m pip install . --no-deps
4141
42-
4342
- name: Validate diffpy.labpdfproc
4443
run: |
4544
pytest --cov

.pre-commit-config.yaml

Lines changed: 26 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
default_language_version:
2-
python: python3
2+
python: python3
33
ci:
4-
autofix_commit_msg: |
5-
[pre-commit.ci] auto fixes from pre-commit hooks
6-
autofix_prs: true
7-
autoupdate_branch: 'pre-commit-autoupdate'
8-
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
9-
autoupdate_schedule: monthly
10-
skip: [no-commit-to-branch]
11-
submodules: false
4+
autofix_commit_msg: |
5+
[pre-commit.ci] auto fixes from pre-commit hooks
6+
autofix_prs: true
7+
autoupdate_branch: "pre-commit-autoupdate"
8+
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
9+
autoupdate_schedule: monthly
10+
skip: [no-commit-to-branch]
11+
submodules: false
1212
repos:
1313
- repo: https://github.com/pre-commit/pre-commit-hooks
1414
rev: v4.6.0
@@ -47,6 +47,20 @@ repos:
4747
- repo: https://github.com/codespell-project/codespell
4848
rev: v2.3.0
4949
hooks:
50-
- id: codespell
51-
additional_dependencies:
52-
- tomli
50+
- id: codespell
51+
additional_dependencies:
52+
- tomli
53+
# prettier - multi formatter for .json, .yml, and .md files
54+
- repo: https://github.com/pre-commit/mirrors-prettier
55+
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
56+
hooks:
57+
- id: prettier
58+
additional_dependencies:
59+
- "prettier@^3.2.4"
60+
# docformatter - PEP 257 compliant docstring formatter
61+
- repo: https://github.com/s-weigand/docformatter
62+
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
63+
hooks:
64+
- id: docformatter
65+
additional_dependencies: [tomli]
66+
args: [--in-place, --config, ./pyproject.toml]

.readthedocs.yaml

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
version: 2
2+
3+
build:
4+
os: "ubuntu-22.04"
5+
tools:
6+
python: "latest"
7+
8+
python:
9+
install:
10+
- requirements: requirements/docs.txt
11+
12+
sphinx:
13+
configuration: doc/source/conf.py

CODE_OF_CONDUCT.rst

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@ Our Pledge
88
We as members, contributors, and leaders pledge to make participation in our
99
community a harassment-free experience for everyone, regardless of age, body
1010
size, visible or invisible disability, ethnicity, sex characteristics, gender
11-
identity and expression, level of experience, education, socio-economic status,
11+
identity and expression, level of experience, education, socioeconomic status,
1212
nationality, personal appearance, race, caste, color, religion, or sexual
1313
identity and orientation.
1414

LICENSE.rst

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
BSD 3-Clause License
22

3-
Copyright (c) 2024, The Trustees of Columbia University
4-
in the City of New York.
3+
Copyright (c) 2025, The Trustees of Columbia University in the City of New York.
54
All rights reserved.
65

76
Redistribution and use in source and binary forms, with or without

news/recut2.rst

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
**Added:**
2+
3+
* Recookiecut with updated ``scikit-package`` to enable docs preview in PRs.
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+
* <news item>
20+
21+
**Security:**
22+
23+
* <news item>

src/diffpy/labpdfproc/__init__.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,8 @@
1212
# See LICENSE.rst for license information.
1313
#
1414
##############################################################################
15-
16-
"""Tools for processing x-ray powder diffraction data
17-
from laboratory sources."""
15+
"""Tools for processing x-ray powder diffraction data from laboratory
16+
sources."""
1817

1918
# package version
2019
from diffpy.labpdfproc.version import __version__

src/diffpy/labpdfproc/functions.py

Lines changed: 17 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -40,8 +40,8 @@ def __init__(
4040
self._get_grid_points()
4141

4242
def _get_grid_points(self):
43-
"""Given a radius and a grid size,
44-
return a grid of points to uniformly sample that circle."""
43+
"""Given a radius and a grid size, return a grid of points to uniformly
44+
sample that circle."""
4545
xs = np.linspace(-self.radius, self.radius, self.npoints)
4646
ys = np.linspace(-self.radius, self.radius, self.npoints)
4747
self.grid = {
@@ -50,8 +50,8 @@ def _get_grid_points(self):
5050
self.total_points_in_grid = len(self.grid)
5151

5252
def _get_entry_exit_coordinates(self, coordinate, angle):
53-
"""Get the coordinates where the beam enters and leaves the circle
54-
for a given angle and grid point.
53+
"""Get the coordinates where the beam enters and leaves the circle for
54+
a given angle and grid point.
5555
5656
It is calculated in the following way:
5757
For the entry coordinate,
@@ -108,9 +108,8 @@ def _get_entry_exit_coordinates(self, coordinate, angle):
108108
return entry_point, exit_point
109109

110110
def _get_path_length(self, grid_point, angle):
111-
"""Return the path length of
112-
a horizontal line entering the circle at the same height
113-
to the grid point then exiting at angle.
111+
"""Return the path length of a horizontal line entering the circle at
112+
the same height to the grid point then exiting at angle.
114113
115114
Parameters
116115
----------
@@ -137,8 +136,8 @@ def _get_path_length(self, grid_point, angle):
137136
return total_distance, primary_distance, secondary_distance
138137

139138
def set_distances_at_angle(self, angle):
140-
"""Given an angle, set the distances from the grid points
141-
to the entry and exit coordinates.
139+
"""Given an angle, set the distances from the grid points to the entry
140+
and exit coordinates.
142141
143142
Parameters
144143
----------
@@ -171,9 +170,11 @@ def set_muls_at_angle(self, angle):
171170

172171

173172
def _cve_brute_force(input_pattern, mud):
174-
"""Compute cve for the given mud on a global grid
175-
using the brute-force method.
176-
Assume mu=mud/2, given that the same mu*D yields the same cve and D/2=1.
173+
"""Compute cve for the given mud on a global grid using the brute-force
174+
method.
175+
176+
Assume mu=mud/2, given that the same mu*D yields the same cve and
177+
D/2=1.
177178
"""
178179
mu_sample_invmm = mud / 2
179180
abs_correction = Gridded_circle(
@@ -201,10 +202,8 @@ def _cve_brute_force(input_pattern, mud):
201202

202203

203204
def _cve_polynomial_interpolation(input_pattern, mud):
204-
"""Compute cve using polynomial interpolation method,
205-
default to brute-force computation if mu*D is
206-
out of the range (0.5 to 7).
207-
"""
205+
"""Compute cve using polynomial interpolation method, default to brute-
206+
force computation if mu*D is out of the range (0.5 to 7)."""
208207
if mud > 7 or mud < 0.5:
209208
warnings.warn(
210209
f"Input mu*D = {mud} is out of the acceptable range "
@@ -287,8 +286,8 @@ def compute_cve(
287286

288287

289288
def apply_corr(input_pattern, absorption_correction):
290-
"""Apply absorption correction to the given diffraction object
291-
with the correction diffraction object.
289+
"""Apply absorption correction to the given diffraction object with the
290+
correction diffraction object.
292291
293292
Parameters
294293
----------

src/diffpy/labpdfproc/tools.py

Lines changed: 21 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -114,10 +114,9 @@ def _expand_user_input(args):
114114

115115

116116
def set_input_lists(args):
117-
"""Set input directory and files.
118-
It takes cli inputs, checks if they are files or directories
119-
and creates a list of files to be processed
120-
which is stored in the args Namespace.
117+
"""Set input directory and files. It takes cli inputs, checks if they are
118+
files or directories and creates a list of files to be processed which is
119+
stored in the args Namespace.
121120
122121
Parameters
123122
----------
@@ -278,8 +277,8 @@ def set_wavelength(args):
278277

279278

280279
def set_xtype(args):
281-
"""Set the xtype based on the given input arguments,
282-
raise an error if xtype is not one of {*XQUANTITIES, }.
280+
"""Set the xtype based on the given input arguments, raise an error if
281+
xtype is not one of {*XQUANTITIES, }.
283282
284283
Parameters
285284
----------
@@ -334,8 +333,8 @@ def _parse_theoretical_input(input_str):
334333

335334

336335
def _set_theoretical_mud_from_density(args):
337-
"""Theoretical estimation of mu*D from
338-
sample composition, energy, and sample mass density."""
336+
"""Theoretical estimation of mu*D from sample composition, energy, and
337+
sample mass density."""
339338
sample_composition, energy, sample_mass_density = _parse_theoretical_input(
340339
args.theoretical_from_density
341340
)
@@ -351,8 +350,8 @@ def _set_theoretical_mud_from_density(args):
351350

352351

353352
def _set_theoretical_mud_from_packing(args):
354-
"""Theoretical estimation of mu*D from
355-
sample composition, energy, and packing fraction."""
353+
"""Theoretical estimation of mu*D from sample composition, energy, and
354+
packing fraction."""
356355
sample_composition, energy, packing_fraction = _parse_theoretical_input(
357356
args.theoretical_from_packing
358357
)
@@ -404,8 +403,8 @@ def _load_key_value_pair(s):
404403

405404

406405
def load_user_metadata(args):
407-
"""Load user metadata into args,
408-
raise ValueError if it is in incorrect format.
406+
"""Load user metadata into args, raise ValueError if it is in incorrect
407+
format.
409408
410409
Parameters
411410
----------
@@ -444,10 +443,9 @@ def load_user_metadata(args):
444443

445444

446445
def load_user_info(args):
447-
"""Load user info into args.
448-
If none is provided, call check_and_build_global_config function
449-
from diffpy.utils to prompt the user for inputs.
450-
Otherwise, call get_user_info with the provided arguments.
446+
"""Load user info into args. If none is provided, call
447+
check_and_build_global_config function from diffpy.utils to prompt the user
448+
for inputs. Otherwise, call get_user_info with the provided arguments.
451449
452450
Parameters
453451
----------
@@ -474,8 +472,8 @@ def load_user_info(args):
474472

475473

476474
def load_package_info(args):
477-
"""Load diffpy.labpdfproc package name and version into args
478-
using get_package_info function from diffpy.utils.
475+
"""Load diffpy.labpdfproc package name and version into args using
476+
get_package_info function from diffpy.utils.
479477
480478
Parameters
481479
----------
@@ -494,10 +492,9 @@ def load_package_info(args):
494492

495493

496494
def preprocessing_args(args):
497-
"""Perform preprocessing on the provided args.
498-
The process includes loading package and user information,
499-
setting input, output, wavelength, anode type, xtype, mu*D,
500-
and loading user metadata.
495+
"""Perform preprocessing on the provided args. The process includes loading
496+
package and user information, setting input, output, wavelength, anode
497+
type, xtype, mu*D, and loading user metadata.
501498
502499
Parameters
503500
----------
@@ -521,8 +518,8 @@ def preprocessing_args(args):
521518

522519

523520
def load_metadata(args, filepath):
524-
"""Load the relevant metadata from args
525-
to write into the header of the output files.
521+
"""Load the relevant metadata from args to write into the header of the
522+
output files.
526523
527524
Parameters
528525
----------

src/diffpy/labpdfproc/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.

tests/test_version.py

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

43
import diffpy.labpdfproc
54

65

76
def test_package_version():
8-
"""Ensure the package version is defined
9-
and not set to the initial placeholder."""
7+
"""Ensure the package version is defined and not set to the initial
8+
placeholder."""
109
assert hasattr(diffpy.labpdfproc, "__version__")
1110
assert diffpy.labpdfproc.__version__ != "0.0.0"

0 commit comments

Comments
 (0)