diff --git a/.codespell/ignore_words.txt b/.codespell/ignore_words.txt index 9757d7c..04b4fcf 100644 --- a/.codespell/ignore_words.txt +++ b/.codespell/ignore_words.txt @@ -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 diff --git a/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md new file mode 100644 index 0000000..1099d86 --- /dev/null +++ b/.github/PULL_REQUEST_TEMPLATE/pull_request_template.md @@ -0,0 +1,15 @@ +### What problem does this PR address? + + + +### What should the reviewer(s) do? + + + + diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index 7f0e3d7..b60acca 100644 --- a/.github/workflows/build-wheel-release-upload.yml +++ b/.github/workflows/build-wheel-release-upload.yml @@ -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: diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml index e0adff0..3588c8a 100644 --- a/.github/workflows/check-news-item.yml +++ b/.github/workflows/check-news-item.yml @@ -3,7 +3,7 @@ name: Check for News on: pull_request_target: branches: - - main + - main jobs: check-news-item: diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml index 5a5883d..c55e217 100644 --- a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -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 diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml index 16fc017..80a58ec 100644 --- a/.github/workflows/tests-on-pr.yml +++ b/.github/workflows/tests-on-pr.yml @@ -39,7 +39,6 @@ jobs: pip install gooey python -m pip install . --no-deps - - name: Validate diffpy.labpdfproc run: | pytest --cov diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 9cf0556..0e4a84d 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -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 @@ -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] diff --git a/.readthedocs.yaml b/.readthedocs.yaml new file mode 100644 index 0000000..47f7a01 --- /dev/null +++ b/.readthedocs.yaml @@ -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 diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst index ff9c356..e8199ca 100644 --- a/CODE_OF_CONDUCT.rst +++ b/CODE_OF_CONDUCT.rst @@ -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. diff --git a/LICENSE.rst b/LICENSE.rst index 95a04ac..9cc6a9d 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -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 diff --git a/news/recut2.rst b/news/recut2.rst new file mode 100644 index 0000000..35f4d9d --- /dev/null +++ b/news/recut2.rst @@ -0,0 +1,23 @@ +**Added:** + +* Recookiecut with updated ``scikit-package`` to enable docs preview in PRs. + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/src/diffpy/labpdfproc/__init__.py b/src/diffpy/labpdfproc/__init__.py index 573b965..3316df6 100644 --- a/src/diffpy/labpdfproc/__init__.py +++ b/src/diffpy/labpdfproc/__init__.py @@ -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__ diff --git a/src/diffpy/labpdfproc/functions.py b/src/diffpy/labpdfproc/functions.py index cf05230..46c9ade 100644 --- a/src/diffpy/labpdfproc/functions.py +++ b/src/diffpy/labpdfproc/functions.py @@ -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 = { @@ -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, @@ -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 ---------- @@ -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 ---------- @@ -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( @@ -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 " @@ -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 ---------- diff --git a/src/diffpy/labpdfproc/tools.py b/src/diffpy/labpdfproc/tools.py index 1586652..5bbce31 100644 --- a/src/diffpy/labpdfproc/tools.py +++ b/src/diffpy/labpdfproc/tools.py @@ -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 ---------- @@ -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 ---------- @@ -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 ) @@ -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 ) @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- @@ -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 ---------- diff --git a/src/diffpy/labpdfproc/version.py b/src/diffpy/labpdfproc/version.py index 9eec494..13d3b31 100644 --- a/src/diffpy/labpdfproc/version.py +++ b/src/diffpy/labpdfproc/version.py @@ -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. diff --git a/tests/test_version.py b/tests/test_version.py index c8bbea5..994c681 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -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"