From bd0614a549b679fb4bee454c30ffd17f77c1f694 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 6 Jan 2025 14:38:19 -0500 Subject: [PATCH 1/4] update .github dir to current cookiecutter --- .github/ISSUE_TEMPLATE/release_checklist.md | 8 ++++---- .github/workflows/build-wheel-release-upload.yml | 2 ++ .github/workflows/check-news-item.yml | 2 +- .github/workflows/matrix-and-codecov-on-merge-to-main.yml | 2 +- .github/workflows/publish-docs-on-release.yml | 4 ---- .github/workflows/tests-on-pr.yml | 2 +- 6 files changed, 9 insertions(+), 11 deletions(-) diff --git a/.github/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index 11df804..fa94779 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -12,11 +12,11 @@ assignees: "" - [ ] All the badges on the README are passing. - [ ] 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. + 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. - [ ] 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. +- [ ] 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: @@ -42,5 +42,5 @@ Please let @sbillinge know that all checks are done and the package is ready for -- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments. -- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures. +- [ ] Run tutorial examples and conduct functional testing using the installation guide in the README. Attach screenshots/results as comments. +- [ ] Documentation (README, tutorials, API references, and websites) is deployed without broken links or missing figures. diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index 218042d..0e48a55 100644 --- a/.github/workflows/build-wheel-release-upload.yml +++ b/.github/workflows/build-wheel-release-upload.yml @@ -11,6 +11,8 @@ jobs: uses: Billingegroup/release-scripts/.github/workflows/_build-wheel-release-upload.yml@v0 with: project: diffpy.fourigui + c_extension: false + github_admin_username: sbillinge secrets: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} PAT_TOKEN: ${{ secrets.PAT_TOKEN }} diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml index 628fe4c..f5eafa3 100644 --- a/.github/workflows/check-news-item.yml +++ b/.github/workflows/check-news-item.yml @@ -6,7 +6,7 @@ on: - main jobs: - build: + check-news-item: uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 with: project: diffpy.fourigui 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 e739c34..927a57a 100644 --- a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -11,7 +11,7 @@ on: workflow_dispatch: jobs: - coverage: + matrix-coverage: uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 with: project: diffpy.fourigui diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml index fb3f8da..efd905b 100644 --- a/.github/workflows/publish-docs-on-release.yml +++ b/.github/workflows/publish-docs-on-release.yml @@ -1,14 +1,10 @@ name: Deploy Documentation on Release on: - release: - types: [published] workflow_dispatch: jobs: docs: - permissions: - contents: write uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 with: project: diffpy.fourigui diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml index 2eedfd9..9cb0637 100644 --- a/.github/workflows/tests-on-pr.yml +++ b/.github/workflows/tests-on-pr.yml @@ -8,7 +8,7 @@ on: workflow_dispatch: jobs: - validate: + tests-on-pr: uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 with: project: diffpy.fourigui From cc14032783992307a34cab3310242ad8ef9cbe85 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 6 Jan 2025 14:38:38 -0500 Subject: [PATCH 2/4] update precommit to current cookiecutter --- .pre-commit-config.yaml | 38 ++++++++++++++++++++++++++------------ 1 file changed, 26 insertions(+), 12 deletions(-) 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] From 0552c75c5ea4e889764787ddd99e5c41f5cbb07b Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 6 Jan 2025 14:57:36 -0500 Subject: [PATCH 3/4] news --- news/workflows.rst | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 news/workflows.rst diff --git a/news/workflows.rst b/news/workflows.rst new file mode 100644 index 0000000..70d9afb --- /dev/null +++ b/news/workflows.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* Modify `.github` directory and `.pre-commit-config.yaml` to comply with renaming of package maintainer. + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* From 4bc59e26ca15cd8d4c824e975861f992bb548fe1 Mon Sep 17 00:00:00 2001 From: Caden Myers Date: Mon, 6 Jan 2025 15:04:13 -0500 Subject: [PATCH 4/4] precommit fixes --- .codecov.yml | 8 +-- .../workflows/build-wheel-release-upload.yml | 2 +- .github/workflows/check-news-item.yml | 2 +- src/diffpy/__init__.py | 1 - src/diffpy/fourigui/__init__.py | 1 - src/diffpy/fourigui/fourigui.py | 59 ++++++++----------- src/diffpy/fourigui/version.py | 1 - tests/test_version.py | 6 +- 8 files changed, 33 insertions(+), 47 deletions(-) diff --git a/.codecov.yml b/.codecov.yml index 5a94096..4af5eb2 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,14 +1,14 @@ coverage: status: - project: # more options at https://docs.codecov.com/docs/commit-status + project: # more options at https://docs.codecov.com/docs/commit-status default: target: auto # use the coverage from the base commit, fail if coverage is lower - threshold: 0% # allow the coverage to drop by + threshold: 0% # allow the coverage to drop by comment: layout: " diff, flags, files" behavior: default require_changes: false - require_base: false # [true :: must have a base report to post] - require_head: false # [true :: must have a head report to post] + require_base: false # [true :: must have a base report to post] + require_head: false # [true :: must have a head report to post] hide_project_coverage: false # [true :: only show coverage on the git diff aka patch coverage] diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index 0e48a55..a76326f 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 f5eafa3..bffeec5 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/src/diffpy/__init__.py b/src/diffpy/__init__.py index 4d4bf70..5d0f50f 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -12,7 +12,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """Blank namespace package for module diffpy.""" diff --git a/src/diffpy/fourigui/__init__.py b/src/diffpy/fourigui/__init__.py index 3ccc189..98bbd12 100644 --- a/src/diffpy/fourigui/__init__.py +++ b/src/diffpy/fourigui/__init__.py @@ -12,7 +12,6 @@ # See LICENSE.rst for license information. # ############################################################################## - """Tool for visualizing 3D diffraction and PDF Images.""" # package version diff --git a/src/diffpy/fourigui/fourigui.py b/src/diffpy/fourigui/fourigui.py index ca7e280..c59b77e 100755 --- a/src/diffpy/fourigui/fourigui.py +++ b/src/diffpy/fourigui/fourigui.py @@ -21,7 +21,7 @@ def __init__(self): self.initUI() def initUI(self): - """Initialize the GUI for fourigui""" + """Initialize the GUI for fourigui.""" self.loaded = False # denotes whether a dataset is loaded self.transformed = False # denotes whether dataset is Fourier transformed @@ -254,11 +254,10 @@ def initUI(self): frame11.place(x=WIDTH // 2, y=HEIGHT // 2) # , height=HEIGHT//2, width=WIDTH//2) def load_cube(self): - """ - loads 3D array in h5py file format from the filename input panel - 3D array is expected to be a reconstructed reciprocal scattering volume - when executed, one slide perpendicular to the selected axis will be plotted in the plot panel - """ + """Loads 3D array in h5py file format from the filename input panel 3D + array is expected to be a reconstructed reciprocal scattering volume + when executed, one slide perpendicular to the selected axis will be + plotted in the plot panel.""" filename = self.filename_entry.get() f = h5py.File(filename, "r") @@ -327,7 +326,7 @@ def load_cube(self): self.intensity_upd_global() def plot_plane(self): - """update plotted plane perpendicular to the selected axis""" + """Update plotted plane perpendicular to the selected axis.""" if self.axis.get() == 0: self.im.set_data(self.cube[self.plane_num.get(), :, :]) elif self.axis.get() == 1: @@ -339,7 +338,7 @@ def plot_plane(self): self.canvas.draw() def colorrange_upd(self): - """change color range in plot""" + """Change color range in plot.""" try: if self.colorbarmin.get() and self.colorbarmax.get(): vmin = float(self.colorbarmin.get()) @@ -359,7 +358,8 @@ def colorrange_upd(self): self.plot_plane() def intensity_upd_local(self): - """show local intensity minimum, maximum and sum of current plotted plane""" + """Show local intensity minimum, maximum and sum of current plotted + plane.""" if self.axis.get() == 0: plane = self.cube[self.plane_num.get(), :, :] elif self.axis.get() == 1: @@ -373,7 +373,7 @@ def intensity_upd_local(self): self.localnanratio["text"] = f"{round(nan_ratio, 2)}" def intensity_upd_global(self): - """Load global intensity minimum, maximum and sum of 3D array""" + """Load global intensity minimum, maximum and sum of 3D array.""" self.intensity_upd_local() nan_ratio = np.count_nonzero(np.isnan(self.cube)) / self.cube.size self.globalmax["text"] = f"{np.format_float_scientific(np.nanmax(self.cube), 1)}" @@ -382,10 +382,8 @@ def intensity_upd_global(self): self.globalnanratio["text"] = "{}".format(round(nan_ratio, 2)) def fft(self): - """ - Fourier transform 3D array from reciprocal to real space - the origin of reciprocal and real space is expected to be the central voxel - """ + """Fourier transform 3D array from reciprocal to real space the origin + of reciprocal and real space is expected to be the central voxel.""" def perform_fft(fftholder): fftholder = np.nan_to_num(fftholder) @@ -438,10 +436,9 @@ def perform_fft(fftholder): self.intensity_upd_global() def ifft(self): - """ - Inverse Fourier transform 3D array from real to reciprocal space - the origin of real and reciprocal space is expected to be the central voxel - """ + """Inverse Fourier transform 3D array from real to reciprocal space the + origin of real and reciprocal space is expected to be the central + voxel.""" if not self.cutoff.get(): self.cube_real = self.cube self.cube = self.cube_reci @@ -455,8 +452,7 @@ def ifft(self): self.intensity_upd_global() def applycutoff(self): - """ - shape the reciprocal-space array + """Shape the reciprocal-space array. reassign all voxels with distance smaller than qmin and greater than qmax to np.nan. @@ -507,9 +503,8 @@ def applycutoff(self): self.intensity_upd_global() def redocutuff(self): - """ - Redo the cutoff operation depending on the current space (real or reciprocal). - """ + """Redo the cutoff operation depending on the current space (real or + reciprocal).""" if self.space.get(): # in real space self.cube_realcut = self.cube if not self.transformed: @@ -522,9 +517,8 @@ def redocutuff(self): self.intensity_upd_global() def newcutoff(self): - """ - Apply a new cutoff based on the current space and cutoff settings. - """ + """Apply a new cutoff based on the current space and cutoff + settings.""" if self.cutoff.get(): if self.space.get() and self.transformed: self.cube = self.cube_real @@ -535,9 +529,8 @@ def newcutoff(self): self.applycutoff() def plot_next_plane(self): - """ - Plot the next plane in the dataset, looping back to the first if at the end. - """ + """Plot the next plane in the dataset, looping back to the first if at + the end.""" n = self.plane_num.get() if n == len(self.cube[self.axis.get()]) - 1: n = 0 @@ -547,9 +540,7 @@ def plot_next_plane(self): self.plot_plane() def animation(self): - """ - slices through the 3D array along the selected axis - """ + """Slices through the 3D array along the selected axis.""" try: if not self.anientry.get(): anispeed = 1 @@ -563,9 +554,7 @@ def animation(self): self.plot_next_plane() def multiple_funcs(*funcs): - """ - Executes multiple functions passed as arguments in sequence. - """ + """Executes multiple functions passed as arguments in sequence.""" for func in funcs: func diff --git a/src/diffpy/fourigui/version.py b/src/diffpy/fourigui/version.py index e8b1019..a21a124 100644 --- a/src/diffpy/fourigui/version.py +++ b/src/diffpy/fourigui/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 4fc6f6a..32b5ed4 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,10 +1,10 @@ -"""Unit tests for __version__.py -""" +"""Unit tests for __version__.py.""" import diffpy.fourigui 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.fourigui, "__version__") assert diffpy.fourigui.__version__ != "0.0.0"