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 1 commit
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
Prev Previous commit
chore: apply formatting and doc updates from recookiecut
  • Loading branch information
yucongalicechen committed May 15, 2025
commit 924615e7862a3bc258a31fc0a8c04836393f40a4
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
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