Skip to content

recut using scikit-package to allow docs preview #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
May 15, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 0 additions & 3 deletions .codespell/ignore_words.txt
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,5 @@
;; abbreviation for "materials" often used in a journal title
mater

;; alternative use of socioeconomic
socio-economic

;; Frobenius norm used in np.linalg.norm
fro
15 changes: 15 additions & 0 deletions .github/PULL_REQUEST_TEMPLATE/pull_request_template.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
### What problem does this PR address?

<!-- Provide a brief overview and link to the issue. Attach outputs, including screenshots (before/after), if helpful for the reviewer. -->

### What should the reviewer(s) do?

<!-- Merge the code, provide feedback, initiate a discussion, etc. -->

<!--
Use the following checklist items when applicable (select only what applies):
- [ ] This PR introduces a public-facing change (e.g., figures, CLI input/output, API).
- [ ] Documentation (e.g., tutorials, examples, README) has been updated.
- [ ] A tracking issue or plan to update documentation exists.
- [ ] This PR affects internal functionality only (no user-facing change).
-->
2 changes: 1 addition & 1 deletion .github/workflows/build-wheel-release-upload.yml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ on:
workflow_dispatch:
push:
tags:
- '*' # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml
- "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml

jobs:
release:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/check-news-item.yml
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@ name: Check for News
on:
pull_request_target:
branches:
- main
- main

jobs:
check-news-item:
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/matrix-and-codecov-on-merge-to-main.yml
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ jobs:
os: [ubuntu-latest, windows-latest, macos-13, macos-14]
python-version: ["3.11", "3.12", "3.13"]
env:
LATEST_PYTHON_VERSION: "3.13"
LATEST_PYTHON_VERSION: "3.13"
steps:
- name: Check out diffpy.labpdfproc
uses: actions/checkout@v4
Expand Down
1 change: 0 additions & 1 deletion .github/workflows/tests-on-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,6 @@ jobs:
pip install gooey
python -m pip install . --no-deps


- name: Validate diffpy.labpdfproc
run: |
pytest --cov
Expand Down
38 changes: 26 additions & 12 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
default_language_version:
python: python3
python: python3
ci:
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: 'pre-commit-autoupdate'
autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate'
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
autofix_commit_msg: |
[pre-commit.ci] auto fixes from pre-commit hooks
autofix_prs: true
autoupdate_branch: "pre-commit-autoupdate"
autoupdate_commit_msg: "[pre-commit.ci] pre-commit autoupdate"
autoupdate_schedule: monthly
skip: [no-commit-to-branch]
submodules: false
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.6.0
Expand Down Expand Up @@ -47,6 +47,20 @@ repos:
- repo: https://github.com/codespell-project/codespell
rev: v2.3.0
hooks:
- id: codespell
additional_dependencies:
- tomli
- id: codespell
additional_dependencies:
- tomli
# prettier - multi formatter for .json, .yml, and .md files
- repo: https://github.com/pre-commit/mirrors-prettier
rev: f12edd9c7be1c20cfa42420fd0e6df71e42b51ea # frozen: v4.0.0-alpha.8
hooks:
- id: prettier
additional_dependencies:
- "prettier@^3.2.4"
# docformatter - PEP 257 compliant docstring formatter
- repo: https://github.com/s-weigand/docformatter
rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c
hooks:
- id: docformatter
additional_dependencies: [tomli]
args: [--in-place, --config, ./pyproject.toml]
13 changes: 13 additions & 0 deletions .readthedocs.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,13 @@
version: 2

build:
os: "ubuntu-22.04"
tools:
python: "latest"

python:
install:
- requirements: requirements/docs.txt

sphinx:
configuration: doc/source/conf.py
2 changes: 1 addition & 1 deletion CODE_OF_CONDUCT.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ Our Pledge
We as members, contributors, and leaders pledge to make participation in our
community a harassment-free experience for everyone, regardless of age, body
size, visible or invisible disability, ethnicity, sex characteristics, gender
identity and expression, level of experience, education, socio-economic status,
identity and expression, level of experience, education, socioeconomic status,
nationality, personal appearance, race, caste, color, religion, or sexual
identity and orientation.

Expand Down
3 changes: 1 addition & 2 deletions LICENSE.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
BSD 3-Clause License

Copyright (c) 2024, The Trustees of Columbia University
in the City of New York.
Copyright (c) 2025, The Trustees of Columbia University in the City of New York.
All rights reserved.

Redistribution and use in source and binary forms, with or without
Expand Down
23 changes: 23 additions & 0 deletions news/recut2.rst
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
**Added:**

* Recookiecut with updated ``scikit-package`` to enable docs preview in PRs.

**Changed:**

* <news item>

**Deprecated:**

* <news item>

**Removed:**

* <news item>

**Fixed:**

* <news item>

**Security:**

* <news item>
5 changes: 2 additions & 3 deletions src/diffpy/labpdfproc/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,8 @@
# See LICENSE.rst for license information.
#
##############################################################################

"""Tools for processing x-ray powder diffraction data
from laboratory sources."""
"""Tools for processing x-ray powder diffraction data from laboratory
sources."""

# package version
from diffpy.labpdfproc.version import __version__
Expand Down
35 changes: 17 additions & 18 deletions src/diffpy/labpdfproc/functions.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,8 +40,8 @@ def __init__(
self._get_grid_points()

def _get_grid_points(self):
"""Given a radius and a grid size,
return a grid of points to uniformly sample that circle."""
"""Given a radius and a grid size, return a grid of points to uniformly
sample that circle."""
xs = np.linspace(-self.radius, self.radius, self.npoints)
ys = np.linspace(-self.radius, self.radius, self.npoints)
self.grid = {
Expand All @@ -50,8 +50,8 @@ def _get_grid_points(self):
self.total_points_in_grid = len(self.grid)

def _get_entry_exit_coordinates(self, coordinate, angle):
"""Get the coordinates where the beam enters and leaves the circle
for a given angle and grid point.
"""Get the coordinates where the beam enters and leaves the circle for
a given angle and grid point.

It is calculated in the following way:
For the entry coordinate,
Expand Down Expand Up @@ -108,9 +108,8 @@ def _get_entry_exit_coordinates(self, coordinate, angle):
return entry_point, exit_point

def _get_path_length(self, grid_point, angle):
"""Return the path length of
a horizontal line entering the circle at the same height
to the grid point then exiting at angle.
"""Return the path length of a horizontal line entering the circle at
the same height to the grid point then exiting at angle.

Parameters
----------
Expand All @@ -137,8 +136,8 @@ def _get_path_length(self, grid_point, angle):
return total_distance, primary_distance, secondary_distance

def set_distances_at_angle(self, angle):
"""Given an angle, set the distances from the grid points
to the entry and exit coordinates.
"""Given an angle, set the distances from the grid points to the entry
and exit coordinates.

Parameters
----------
Expand Down Expand Up @@ -171,9 +170,11 @@ def set_muls_at_angle(self, angle):


def _cve_brute_force(input_pattern, mud):
"""Compute cve for the given mud on a global grid
using the brute-force method.
Assume mu=mud/2, given that the same mu*D yields the same cve and D/2=1.
"""Compute cve for the given mud on a global grid using the brute-force
method.

Assume mu=mud/2, given that the same mu*D yields the same cve and
D/2=1.
"""
mu_sample_invmm = mud / 2
abs_correction = Gridded_circle(
Expand Down Expand Up @@ -201,10 +202,8 @@ def _cve_brute_force(input_pattern, mud):


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


def apply_corr(input_pattern, absorption_correction):
"""Apply absorption correction to the given diffraction object
with the correction diffraction object.
"""Apply absorption correction to the given diffraction object with the
correction diffraction object.

Parameters
----------
Expand Down
45 changes: 21 additions & 24 deletions src/diffpy/labpdfproc/tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -114,10 +114,9 @@ def _expand_user_input(args):


def set_input_lists(args):
"""Set input directory and files.
It takes cli inputs, checks if they are files or directories
and creates a list of files to be processed
which is stored in the args Namespace.
"""Set input directory and files. It takes cli inputs, checks if they are
files or directories and creates a list of files to be processed which is
stored in the args Namespace.

Parameters
----------
Expand Down Expand Up @@ -278,8 +277,8 @@ def set_wavelength(args):


def set_xtype(args):
"""Set the xtype based on the given input arguments,
raise an error if xtype is not one of {*XQUANTITIES, }.
"""Set the xtype based on the given input arguments, raise an error if
xtype is not one of {*XQUANTITIES, }.

Parameters
----------
Expand Down Expand Up @@ -334,8 +333,8 @@ def _parse_theoretical_input(input_str):


def _set_theoretical_mud_from_density(args):
"""Theoretical estimation of mu*D from
sample composition, energy, and sample mass density."""
"""Theoretical estimation of mu*D from sample composition, energy, and
sample mass density."""
sample_composition, energy, sample_mass_density = _parse_theoretical_input(
args.theoretical_from_density
)
Expand All @@ -351,8 +350,8 @@ def _set_theoretical_mud_from_density(args):


def _set_theoretical_mud_from_packing(args):
"""Theoretical estimation of mu*D from
sample composition, energy, and packing fraction."""
"""Theoretical estimation of mu*D from sample composition, energy, and
packing fraction."""
sample_composition, energy, packing_fraction = _parse_theoretical_input(
args.theoretical_from_packing
)
Expand Down Expand Up @@ -404,8 +403,8 @@ def _load_key_value_pair(s):


def load_user_metadata(args):
"""Load user metadata into args,
raise ValueError if it is in incorrect format.
"""Load user metadata into args, raise ValueError if it is in incorrect
format.

Parameters
----------
Expand Down Expand Up @@ -444,10 +443,9 @@ def load_user_metadata(args):


def load_user_info(args):
"""Load user info into args.
If none is provided, call check_and_build_global_config function
from diffpy.utils to prompt the user for inputs.
Otherwise, call get_user_info with the provided arguments.
"""Load user info into args. If none is provided, call
check_and_build_global_config function from diffpy.utils to prompt the user
for inputs. Otherwise, call get_user_info with the provided arguments.

Parameters
----------
Expand All @@ -474,8 +472,8 @@ def load_user_info(args):


def load_package_info(args):
"""Load diffpy.labpdfproc package name and version into args
using get_package_info function from diffpy.utils.
"""Load diffpy.labpdfproc package name and version into args using
get_package_info function from diffpy.utils.

Parameters
----------
Expand All @@ -494,10 +492,9 @@ def load_package_info(args):


def preprocessing_args(args):
"""Perform preprocessing on the provided args.
The process includes loading package and user information,
setting input, output, wavelength, anode type, xtype, mu*D,
and loading user metadata.
"""Perform preprocessing on the provided args. The process includes loading
package and user information, setting input, output, wavelength, anode
type, xtype, mu*D, and loading user metadata.

Parameters
----------
Expand All @@ -521,8 +518,8 @@ def preprocessing_args(args):


def load_metadata(args, filepath):
"""Load the relevant metadata from args
to write into the header of the output files.
"""Load the relevant metadata from args to write into the header of the
output files.

Parameters
----------
Expand Down
1 change: 0 additions & 1 deletion src/diffpy/labpdfproc/version.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,6 @@
# See LICENSE.rst for license information.
#
##############################################################################

"""Definition of __version__."""

# We do not use the other three variables, but can be added back if needed.
Expand Down
7 changes: 3 additions & 4 deletions tests/test_version.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,10 @@
"""Unit tests for __version__.py
"""
"""Unit tests for __version__.py."""

import diffpy.labpdfproc


def test_package_version():
"""Ensure the package version is defined
and not set to the initial placeholder."""
"""Ensure the package version is defined and not set to the initial
placeholder."""
assert hasattr(diffpy.labpdfproc, "__version__")
assert diffpy.labpdfproc.__version__ != "0.0.0"
Loading