From f6793d73b63b0560d1eda76f03eeff913a6d8e12 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 15 May 2025 15:34:23 -0400 Subject: [PATCH 1/3] recut to allow docs preview --- .codespell/ignore_words.txt | 3 -- .github/ISSUE_TEMPLATE/release_checklist.md | 14 +++---- .../pull_request_template.md | 15 ++++++++ .pre-commit-config.yaml | 38 +++++++++++++------ .readthedocs.yaml | 13 +++++++ CODE_OF_CONDUCT.rst | 2 +- LICENSE.rst | 3 +- README.rst | 6 +-- news/recut2.rst | 23 +++++++++++ 9 files changed, 88 insertions(+), 29 deletions(-) create mode 100644 .github/PULL_REQUEST_TEMPLATE/pull_request_template.md create mode 100644 .readthedocs.yaml create mode 100644 news/recut2.rst 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/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index fa94779..6107962 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -13,30 +13,30 @@ assignees: "" - [ ] License information is verified as correct. If you are unsure, please comment below. - [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are missing), tutorials, and other human-written text is up-to-date with any changes in the code. -- [ ] Installation instructions in the README, documentation, and the website (e.g., diffpy.org) are updated. +- [ ] Installation instructions in the README, documentation, and the website are updated. - [ ] Successfully run any tutorial examples or do functional testing with the latest Python version. - [ ] Grammar and writing quality are checked (no typos). - [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release. -Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: +Please tag the maintainer (e.g., @username) in the comment here when you are ready for the PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: ### PyPI/GitHub full-release preparation checklist: - [ ] Create a new conda environment and install the rc from PyPI (`pip install ==??`) - [ ] License information on PyPI is correct. -- [ ] Docs are deployed successfully to `https://www.diffpy.org/`. +- [ ] Docs are deployed successfully to `https:///`. - [ ] Successfully run all tests, tutorial examples or do functional testing. -Please let @sbillinge know that all checks are done and the package is ready for full release. +Please let the maintainer know that all checks are done and the package is ready for full release. ### conda-forge release preparation checklist: - + - [ ] Ensure that the full release has appeared on PyPI successfully. - [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock. -- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions. -- [ ] Tag @sbillinge and @bobleesj for conda-forge release. +- [ ] Close any open issues on the feedstock. Reach out to the maintainer if you have questions. +- [ ] Tag the maintainer for conda-forge release. ### Post-release checklist 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/.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/README.rst b/README.rst index 358c54d..dc4cb76 100644 --- a/README.rst +++ b/README.rst @@ -131,9 +131,7 @@ You may consult our `online documentation `_ is the discussion forum for general questions and discussions about the use of diffpy.labpdfproc. Please join the diffpy.labpdfproc users community by joining the Google group. The diffpy.labpdfproc project welcomes your expertise and enthusiasm! - -If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. Feel free to fork the project and contribute. To install diffpy.labpdfproc in a development mode, with its sources being directly used by Python @@ -161,4 +159,4 @@ Before contributing, please read our `Code of Conduct `_ or email Prof. Simon Billinge at sb2896@columbia.edu. +For more information on diffpy.labpdfproc please visit the project `web-page `_ or email Simon Billinge at sb2896@columbia.edu. 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:** + +* From 8325d657ef116c6e32e0a00687ba630b3edfc01f Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 15 May 2025 15:39:17 -0400 Subject: [PATCH 2/3] fix: revert unintended changes --- .github/ISSUE_TEMPLATE/release_checklist.md | 14 +++++++------- README.rst | 6 ++++-- 2 files changed, 11 insertions(+), 9 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index 6107962..fa94779 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -13,30 +13,30 @@ assignees: "" - [ ] License information is verified as correct. If you are unsure, please comment below. - [ ] Locally rendered documentation contains all appropriate pages, including API references (check no modules are missing), tutorials, and other human-written text is up-to-date with any changes in the code. -- [ ] Installation instructions in the README, documentation, and the website are updated. +- [ ] Installation instructions in the README, documentation, and the website (e.g., diffpy.org) are updated. - [ ] Successfully run any tutorial examples or do functional testing with the latest Python version. - [ ] Grammar and writing quality are checked (no typos). - [ ] Install `pip install build twine`, run `python -m build` and `twine check dist/*` to ensure that the package can be built and is correctly formatted for PyPI release. -Please tag the maintainer (e.g., @username) in the comment here when you are ready for the PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: +Please mention @sbillinge here when you are ready for PyPI/GitHub release. Include any additional comments necessary, such as version information and details about the pre-release here: ### PyPI/GitHub full-release preparation checklist: - [ ] Create a new conda environment and install the rc from PyPI (`pip install ==??`) - [ ] License information on PyPI is correct. -- [ ] Docs are deployed successfully to `https:///`. +- [ ] Docs are deployed successfully to `https://www.diffpy.org/`. - [ ] Successfully run all tests, tutorial examples or do functional testing. -Please let the maintainer know that all checks are done and the package is ready for full release. +Please let @sbillinge know that all checks are done and the package is ready for full release. ### conda-forge release preparation checklist: - + - [ ] Ensure that the full release has appeared on PyPI successfully. - [ ] New package dependencies listed in `conda.txt` and `test.txt` are added to `meta.yaml` in the feedstock. -- [ ] Close any open issues on the feedstock. Reach out to the maintainer if you have questions. -- [ ] Tag the maintainer for conda-forge release. +- [ ] Close any open issues on the feedstock. Reach out to @bobleesj if you have questions. +- [ ] Tag @sbillinge and @bobleesj for conda-forge release. ### Post-release checklist diff --git a/README.rst b/README.rst index dc4cb76..358c54d 100644 --- a/README.rst +++ b/README.rst @@ -131,7 +131,9 @@ You may consult our `online documentation `_ and/or `submit a fix as a PR `_. +`Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.labpdfproc. Please join the diffpy.labpdfproc users community by joining the Google group. The diffpy.labpdfproc project welcomes your expertise and enthusiasm! + +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. Feel free to fork the project and contribute. To install diffpy.labpdfproc in a development mode, with its sources being directly used by Python @@ -159,4 +161,4 @@ Before contributing, please read our `Code of Conduct `_ or email Simon Billinge at sb2896@columbia.edu. +For more information on diffpy.labpdfproc please visit the project `web-page `_ or email Prof. Simon Billinge at sb2896@columbia.edu. From 924615e7862a3bc258a31fc0a8c04836393f40a4 Mon Sep 17 00:00:00 2001 From: yucongalicechen Date: Thu, 15 May 2025 15:48:00 -0400 Subject: [PATCH 3/3] chore: apply formatting and doc updates from recookiecut --- .../workflows/build-wheel-release-upload.yml | 2 +- .github/workflows/check-news-item.yml | 2 +- .../matrix-and-codecov-on-merge-to-main.yml | 2 +- .github/workflows/tests-on-pr.yml | 1 - src/diffpy/labpdfproc/__init__.py | 5 +-- src/diffpy/labpdfproc/functions.py | 35 +++++++-------- src/diffpy/labpdfproc/tools.py | 45 +++++++++---------- src/diffpy/labpdfproc/version.py | 1 - tests/test_version.py | 7 ++- 9 files changed, 46 insertions(+), 54 deletions(-) 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/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"