diff --git a/.github/ISSUE_TEMPLATE/release_checklist.md b/.github/ISSUE_TEMPLATE/release_checklist.md index 56bcd01..56c5fca 100644 --- a/.github/ISSUE_TEMPLATE/release_checklist.md +++ b/.github/ISSUE_TEMPLATE/release_checklist.md @@ -11,12 +11,13 @@ assignees: "" - [ ] All PRs/issues attached to the release are merged. - [ ] 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. +- [ ] Locally rendered documentation contains all appropriate pages, tutorials, and other human-written text is up-to-date with any changes in the code. +- [ ] All API references are included. To check this, run `conda install scikit-package` and then `package build api-doc`. Review any edits made by rerendering the docs locally. - [ ] 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. +- [ ] Dispatch matrix testing to test the release on all Python versions and systems. If you do not have permission to run this workflow, tag the maintainer and say `@maintainer, please dispatch matrix testing workflow`. 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: diff --git a/.github/workflows/build-and-publish-docs-on-dispatch.yml b/.github/workflows/build-and-publish-docs-on-dispatch.yml new file mode 100644 index 0000000..0f2f7f8 --- /dev/null +++ b/.github/workflows/build-and-publish-docs-on-dispatch.yml @@ -0,0 +1,18 @@ +name: Build and Publish Docs on Dispatch + +on: + workflow_dispatch: + +jobs: + get-python-version: + uses: scikit-package/release-scripts/.github/workflows/_get-python-version-latest.yml@v0 + with: + python_version: 0 + + docs: + uses: scikit-package/release-scripts/.github/workflows/_release-docs.yml@v0 + with: + project: diffpy.srxplanar + c_extension: false + headless: false + python_version: ${{ fromJSON(needs.get-python-version.outputs.latest_python_version) }} diff --git a/.github/workflows/build-wheel-release-upload.yml b/.github/workflows/build-wheel-release-upload.yml index d4ccc73..dc80421 100644 --- a/.github/workflows/build-wheel-release-upload.yml +++ b/.github/workflows/build-wheel-release-upload.yml @@ -1,19 +1,76 @@ -name: Release (GitHub/PyPI) and Deploy Docs +name: Build Wheel and Release +# Trigger on tag push or manual dispatch. +# Tag and release privilege are verified inside the reusable workflow. on: workflow_dispatch: push: tags: - - "*" # Trigger on all tags initially, but tag and release privilege are verified in _build-wheel-release-upload.yml + - "*" + +# ── Release modality ────────────────────────────────────────────────────────── +# Three options are provided below. Only ONE job should be active at a time. +# To switch: comment out the active job and uncomment your preferred option, +# then commit the change to main before tagging a release. +# ───────────────────────────────────────────────────────────────────────────── jobs: + # Option 1 (default): Release to GitHub, publish to PyPI, and deploy docs. + # + # The wheel is uploaded to PyPI so users can install with `pip install`. + # A GitHub release is created with the changelog as the release body, and + # the Sphinx documentation is rebuilt and deployed to GitHub Pages. + # + # Choose this for open-source packages distributed via PyPI and/or + # conda-forge where broad public availability is the goal. build-release: uses: scikit-package/release-scripts/.github/workflows/_build-wheel-release-upload.yml@v0 with: project: diffpy.srxplanar c_extension: false - maintainer_GITHUB_username: sbillinge - + maintainer_github_username: sbillinge secrets: PYPI_TOKEN: ${{ secrets.PYPI_TOKEN }} PAT_TOKEN: ${{ secrets.PAT_TOKEN }} + + # Option 2: Release to GitHub and deploy docs, without publishing to PyPI. + # + # A GitHub release is created and the Sphinx docs are deployed, but the + # wheel is not uploaded to PyPI. The source code remains publicly visible + # on GitHub and can be installed directly from there. + # + # Choose this when the package is public but you prefer to keep it off the + # default pip index — for example, if you distribute via conda-forge only, + # or if the package is not yet ready for a permanent PyPI presence. + # + # To use: comment out Option 1 above and uncomment the lines below. + # build-release-no-pypi: + # uses: scikit-package/release-scripts/.github/workflows/_build-release-github-no-pypi.yml@v0 + # with: + # project: diffpy.srxplanar + # c_extension: false + # maintainer_github_username: sbillinge + # secrets: + # PAT_TOKEN: ${{ secrets.PAT_TOKEN }} + + # Option 3: Release to GitHub with wheel, license, and instructions bundled + # as a downloadable zip attached to the GitHub release asset. + # + # The wheel is built and packaged together with INSTRUCTIONS.txt and the + # LICENSE file into a zip that is attached directly to the GitHub release. + # Users with access to the (private) repo download the zip, follow the + # instructions inside, and install locally with pip. No PyPI or conda-forge + # upload occurs, and no docs are deployed. + # + # Choose this for private or restricted packages where distribution must be + # controlled: only users with repo access can download the release asset, + # making the GitHub release itself the distribution channel. + # + # To use: comment out Option 1 above and uncomment the lines below. + # build-release-private: + # uses: scikit-package/release-scripts/.github/workflows/_build-release-github-private-pure.yml@v0 + # with: + # project: diffpy.srxplanar + # maintainer_github_username: sbillinge + # secrets: + # PAT_TOKEN: ${{ secrets.PAT_TOKEN }} diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml index c1588da..cb7e3dc 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 # GitHub does not evaluate expressions in trigger filters; edit this value if your base branch is not main jobs: check-news-item: diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov.yml similarity index 84% rename from .github/workflows/matrix-and-codecov-on-merge-to-main.yml rename to .github/workflows/matrix-and-codecov.yml index 9556c23..10c1d6d 100644 --- a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml +++ b/.github/workflows/matrix-and-codecov.yml @@ -1,9 +1,9 @@ -name: CI +name: Matrix and Codecov on: - push: - branches: - - main + # push: + # branches: + # - main release: types: - prereleased @@ -17,6 +17,5 @@ jobs: project: diffpy.srxplanar c_extension: false headless: false - secrets: CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.gitignore b/.gitignore index c717e59..702c457 100644 --- a/.gitignore +++ b/.gitignore @@ -43,3 +43,6 @@ nosetests.xml setup.cfg /diffpy/srxplanar/version.cfg /diffpy/confutils/version.cfg + +# PyCharm / IDEs +.idea/ diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index 0e4a84d..bab6cac 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -11,7 +11,7 @@ ci: submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.6.0 + rev: v6.0.0 hooks: - id: check-yaml - id: end-of-file-fixer @@ -21,31 +21,31 @@ repos: - id: check-toml - id: check-added-large-files - repo: https://github.com/psf/black - rev: 24.4.2 + rev: 26.5.1 hooks: - id: black - repo: https://github.com/pycqa/flake8 - rev: 7.0.0 + rev: 7.3.0 hooks: - id: flake8 - repo: https://github.com/pycqa/isort - rev: 5.13.2 + rev: 9.0.0a3 hooks: - id: isort args: ["--profile", "black"] - repo: https://github.com/kynan/nbstripout - rev: 0.7.1 + rev: 0.9.1 hooks: - id: nbstripout - repo: https://github.com/pre-commit/pre-commit-hooks - rev: v4.4.0 + rev: v6.0.0 hooks: - id: no-commit-to-branch name: Prevent Commit to Main Branch args: ["--branch", "main"] stages: [pre-commit] - repo: https://github.com/codespell-project/codespell - rev: v2.3.0 + rev: v2.4.3 hooks: - id: codespell additional_dependencies: @@ -58,8 +58,8 @@ repos: additional_dependencies: - "prettier@^3.2.4" # docformatter - PEP 257 compliant docstring formatter - - repo: https://github.com/s-weigand/docformatter - rev: 5757c5190d95e5449f102ace83df92e7d3b06c6c + - repo: https://github.com/PyCQA/docformatter + rev: v1.7.8 hooks: - id: docformatter additional_dependencies: [tomli] diff --git a/CHANGELOG.rst b/CHANGELOG.rst index a392df4..530bd63 100644 --- a/CHANGELOG.rst +++ b/CHANGELOG.rst @@ -20,4 +20,3 @@ Release notes * Remove local clone of srxconfutils and replace with package from pypi * Removed glob of user home in load-image - diff --git a/CODE-OF-CONDUCT.rst b/CODE-OF-CONDUCT.rst index e8199ca..25fafe2 100644 --- a/CODE-OF-CONDUCT.rst +++ b/CODE-OF-CONDUCT.rst @@ -67,7 +67,7 @@ Enforcement Instances of abusive, harassing, or otherwise unacceptable behavior may be reported to the community leaders responsible for enforcement at -sb2896@columbia.edu. All complaints will be reviewed and investigated promptly and fairly. +sbillinge@ucsb.edu. All complaints will be reviewed and investigated promptly and fairly. All community leaders are obligated to respect the privacy and security of the reporter of any incident. diff --git a/LICENSE.rst b/LICENSE.rst index db4e4f5..009ffe6 100644 --- a/LICENSE.rst +++ b/LICENSE.rst @@ -2,6 +2,7 @@ BSD 3-Clause License Copyright (c) 2008-2025, The Trustees of Columbia University in the City of New York. Copyright (c) 1994-2014, Christoph Gohlke +Copyright (c) 2026, Billinge Group Members and The DiffPy Team. All rights reserved. Redistribution and use in source and binary forms, with or without diff --git a/MANIFEST.in b/MANIFEST.in index 0356ab2..f1a78ee 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,7 +1,6 @@ graft src graft tests graft requirements -graft docs/examples include AUTHORS.rst LICENSE*.rst README.rst diff --git a/README.rst b/README.rst index ba7d76b..af07206 100644 --- a/README.rst +++ b/README.rst @@ -15,8 +15,8 @@ .. |Black| image:: https://img.shields.io/badge/code_style-black-black :target: https://github.com/psf/black -.. |CI| image:: https://github.com/diffpy/diffpy.cmi/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg - :target: https://github.com/diffpy/diffpy.srxplanar/actions/workflows/matrix-and-codecov-on-merge-to-main.yml +.. |CI| image:: https://github.com/diffpy/diffpy.srxplanar/actions/workflows/matrix-and-codecov.yml/badge.svg + :target: https://github.com/diffpy/diffpy.srxplanar/actions/workflows/matrix-and-codecov.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.srxplanar/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.srxplanar @@ -36,7 +36,7 @@ .. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue :target: https://github.com/diffpy/diffpy.srxplanar/issues -This is part of xPDFsuite package. +2D diffraction image integration using non splitting pixel algorithm diffpy.srxplanar package provides 2D diffraction image integration using non splitting pixel algorithm. And it can estimate and propagate statistic @@ -118,7 +118,7 @@ Support and Contribute 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. To install diffpy.srxplanar +Feel free to fork the project and contribute. To install diffpy.srxplanar in a development mode, with its sources being directly used by Python rather than copied to a package directory, use the following in the root directory :: @@ -144,7 +144,7 @@ Before contributing, please read our `Code of Conduct `_ or email Simon Billinge at sb2896@columbia.edu. +For more information on diffpy.srxplanar please visit the project `web-page `_ or email the maintainers ``Simon Billinge(sbillinge@ucsb.edu)``. Acknowledgements ---------------- diff --git a/cookiecutter.json b/cookiecutter.json index 1bfa80e..2a50b0a 100644 --- a/cookiecutter.json +++ b/cookiecutter.json @@ -1,10 +1,12 @@ { - "maintainer_name": "Simon Billinge", - "maintainer_email": "sb2896@columbia.edu", - "maintainer_github_username": "sbillinge", - "contributors": "Xiaohao Yang and Billinge Group members", - "license_holders": "The Trustees of Columbia University in the City of New York", + "author_names": "Simon Billinge", + "author_emails": "sbillinge@ucsb.edu", + "maintainer_names": "Simon Billinge", + "maintainer_emails": "sbillinge@ucsb.edu", + "maintainer_github_usernames": "sbillinge", + "contributors": "Billinge Group Members", "project_name": "diffpy.srxplanar", + "license_holders": "Billinge Group Members and The DiffPy Team", "github_username_or_orgname": "diffpy", "github_repo_name": "diffpy.srxplanar", "conda_pypi_package_dist_name": "diffpy.srxplanar", diff --git a/docs/source/conf.py b/docs/source/conf.py index c5cdd24..a87797d 100644 --- a/docs/source/conf.py +++ b/docs/source/conf.py @@ -1,7 +1,7 @@ #!/usr/bin/env python # -*- coding: utf-8 -*- # -# diffpy.srxplanar documentation build configuration file, created by +# diffpy.srxplanar documentation build configuration file, created by # noqa: E501 # sphinx-quickstart on Thu Jan 30 15:49:41 2014. # # This file is execfile()d with the current directory set to its @@ -22,17 +22,17 @@ try: fullversion = version("diffpy.srxplanar") except Exception: - fullversion = "No version found. The correct version will appear in the released version." + fullversion = "No version found. The correct version will appear in the released version." # noqa: E501 # If extensions (or modules to document with autodoc) are in another directory, # add these directories to sys.path here. If the directory is relative to the -# documentation root, use Path().resolve() to make it absolute, like shown here. +# documentation root, use Path().resolve() to make it absolute, like shown here. # noqa: E501 # sys.path.insert(0, str(Path(".").resolve())) sys.path.insert(0, str(Path("../..").resolve())) sys.path.insert(0, str(Path("../../src").resolve())) # abbreviations -ab_authors = "Xiaohao Yang and Billinge Group members" +ab_authors = "Xiaohao Yang and Billinge Group Members" # -- General configuration ------------------------------------------------ @@ -50,7 +50,7 @@ "sphinx.ext.intersphinx", "sphinx_rtd_theme", "sphinx_copybutton", - "m2r", + "m2r2", ] # Add any paths that contain templates here, relative to this directory. @@ -69,7 +69,7 @@ # General information about the project. project = "diffpy.srxplanar" -copyright = "%Y, The Trustees of Columbia University in the City of New York" +copyright = "%Y, Billinge Group Members and The DiffPy Team" # The version info for the project you're documenting, acts as replacement for # |version| and |release|, also used in various other places throughout the diff --git a/docs/source/img/.placeholder b/docs/source/img/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/docs/source/index.rst b/docs/source/index.rst index 2933b6d..2d46e3f 100644 --- a/docs/source/index.rst +++ b/docs/source/index.rst @@ -4,13 +4,9 @@ .. |title| replace:: diffpy.srxplanar documentation -| Software version |release| -| Last updated |today|. - -diffpy.srxplanar package provides 2D diffraction image integration using -non splitting pixel algorithm. And it can estimate and propagate statistic -uncertainty of raw counts and integrated intensity. If you are using this -software. If you use this program to do productive scientific research that +``diffpy.srxplanar`` - The diffpy.srxplanar package provides 2D diffraction image integration using +non splitting pixel algorithm. It can also estimate and propagate statistic +uncertainty of raw counts and integrated intensity. If you use this program to do productive scientific research that leads to publication, we kindly ask that you acknowledge use of the program by citing the following paper in your publication: @@ -18,11 +14,22 @@ by citing the following paper in your publication: statistical uncertainties on powder diffraction and small angle scattering data from 2-D x-ray detectors, arXiv:1309.3614 +| Software version |release| +| Last updated |today|. + +=============== +Getting started +=============== + +Welcome to the ``diffpy.srxplanar`` documentation! + +To get started, please visit the :ref:`Getting started ` page. + ======= Authors ======= -``diffpy.srxplanar`` is developed by Xiaohao Yang and Billinge Group members. The maintainer for this project is Simon Billinge. For a detailed list of contributors see +``diffpy.srxplanar`` is developed by Xiaohao Yang and Billinge Group Members. This project is maintained by Simon Billinge. For a detailed list of contributors see https://github.com/diffpy/diffpy.srxplanar/graphs/contributors. ============ @@ -44,9 +51,9 @@ Table of contents .. toctree:: :maxdepth: 2 + getting-started Package API - Modules - Release notes + release license ======= diff --git a/docs/source/license.rst b/docs/source/license.rst index 4b57678..3cd43a0 100644 --- a/docs/source/license.rst +++ b/docs/source/license.rst @@ -10,6 +10,7 @@ OPEN SOURCE LICENSE AGREEMENT BSD 3-Clause License Copyright (c) 2008-2025, The Trustees of Columbia University in the City of New York. +Copyright (c) 2026, Billinge Group Members and The DiffPy Team. All Rights Reserved. Redistribution and use in source and binary forms, with or without diff --git a/docs/source/snippets/.placeholder b/docs/source/snippets/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/news/scikit-package-update.rst b/news/scikit-package-update.rst new file mode 100644 index 0000000..dc3df4b --- /dev/null +++ b/news/scikit-package-update.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Updated project scaffolding to latest scikit-package standards. + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index cfd81eb..5f2c873 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,10 +6,10 @@ build-backend = "setuptools.build_meta" name = "diffpy.srxplanar" dynamic=['version', 'dependencies'] authors = [ - { name="Simon Billinge", email="sb2896@columbia.edu" }, + {name='Simon Billinge', email='sbillinge@ucsb.edu'}, ] maintainers = [ - { name="Simon Billinge", email="sb2896@columbia.edu" }, + {name='Simon Billinge', email='sbillinge@ucsb.edu'}, ] description = "Srxplanar processes data from 2D detectors before propagating it to PDFgetX3" keywords = ['diffpy', 'pdf', 'data interpretation'] diff --git a/requirements/build.txt b/requirements/build.txt new file mode 100644 index 0000000..e69de29 diff --git a/requirements/docs.txt b/requirements/docs.txt index 5f34c6e..1de813f 100644 --- a/requirements/docs.txt +++ b/requirements/docs.txt @@ -2,4 +2,4 @@ sphinx sphinx_rtd_theme sphinx-copybutton doctr -m2r +m2r2 diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index b4a5565..729d49d 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -2,9 +2,11 @@ ############################################################################## # # (c) 2010-2025 The Trustees of Columbia University in the City of New York. +# (c) 2026 Billinge Group Members and The DiffPy Team. # All rights reserved. # -# File coded by: Xiaohao Yang and Billinge Group members. +# File coded by: Xiaohao Yang, Billinge Group members, +# and community contributors. # # See GitHub contributions for a more detailed list of contributors. # https://github.com/diffpy/diffpy.srxplanar/graphs/contributors diff --git a/src/diffpy/srxplanar/__init__.py b/src/diffpy/srxplanar/__init__.py index 4c4ed1c..4807157 100644 --- a/src/diffpy/srxplanar/__init__.py +++ b/src/diffpy/srxplanar/__init__.py @@ -2,9 +2,10 @@ ############################################################################## # # (c) 2010-2025 The Trustees of Columbia University in the City of New York. +# (c) 2026 Billinge Group Members and The DiffPy Team. # All rights reserved. # -# File coded by: Xiaohao Yang, Simon Billinge, Billinge Group members. +# File coded by: Xiaohao Yang and Billinge Group members. # # See GitHub contributions for a more detailed list of contributors. # https://github.com/diffpy/diffpy.srxplanar/graphs/contributors @@ -12,13 +13,11 @@ # See LICENSE.rst for license information. # ############################################################################## -"""Distance Printer, calculate the inter atomic distances. - -Part of xPDFsuite -""" +"""2D diffraction image integration using non splitting pixel +algorithm.""" # package version -from diffpy.srxplanar.version import __version__ +from diffpy.srxplanar.version import __version__ # noqa # silence the pyflakes syntax checker assert __version__ or True diff --git a/src/diffpy/srxplanar/calculate.py b/src/diffpy/srxplanar/calculate.py index 13dc66a..127247c 100644 --- a/src/diffpy/srxplanar/calculate.py +++ b/src/diffpy/srxplanar/calculate.py @@ -130,7 +130,6 @@ def intensity(self, pic): :return: 2d array, [tthorq, intensity, unceratinty] or [tthorq, intensity] """ - intensity = self.calculateIntensity(pic) if self.uncertaintyenable: std = np.sqrt(self.calculateVariance(pic)) @@ -177,7 +176,6 @@ def calculateIntensity(self, pic): corrected :return: 1d array, 1D integrated intensity """ - maskedmatrix, pic = self.getMaskedmatrixPic(pic) intensity = np.histogram(maskedmatrix, self.bin_edges, weights=pic)[0] @@ -246,7 +244,6 @@ def genTTHMatrix(self): :return: 2d array, two theta angle (in radians) of each pixel's center """ - sinr = np.sin(-self.rotation) cosr = np.cos(-self.rotation) sint = np.sin(self.tilt) @@ -302,9 +299,11 @@ def genQMatrix(self): return Q def genCorrectionMatrix(self): - """Generate correction matrix. multiple the 2D raw counts array - by this correction matrix to get corrected raw counts. It will - calculate solid angle correction or polarization correction. + """Generate correction matrix. + + Multiply the 2D raw counts array by this correction matrix to + get corrected raw counts. It will calculate solid angle + correction or polarization correction. :return: 2d array, correction matrix to apply on the image """ diff --git a/src/diffpy/srxplanar/loadimage.py b/src/diffpy/srxplanar/loadimage.py index 579a835..3593315 100644 --- a/src/diffpy/srxplanar/loadimage.py +++ b/src/diffpy/srxplanar/loadimage.py @@ -67,8 +67,10 @@ def flip_image(self, pic): return pic def load_image(self, filename): - """Load image file. If loading fails (e.g. incomplete file), - retry for 5 seconds (10×0.5s). + """Load image file. + + If loading fails (e.g. incomplete file), retry for 5 seconds + (10×0.5s). :param filename: str or Path, image file name or path :return: 2D ndarray, flipped image array @@ -119,7 +121,6 @@ def genFileList( file :return: list of str, a list of filenames """ - fileset = self.genFileSet( filenames, opendir, includepattern, excludepattern, fullpath ) diff --git a/src/diffpy/srxplanar/mask.py b/src/diffpy/srxplanar/mask.py index 7dc45d1..9249c6a 100644 --- a/src/diffpy/srxplanar/mask.py +++ b/src/diffpy/srxplanar/mask.py @@ -69,8 +69,9 @@ def __init__(self, p, calculate): return def staticMask(self, maskfile=None): - """Create a static mask according existing mask file. This mask - remain unchanged for different images. + """Create a static mask according existing mask file. + + This mask remain unchanged for different images. :param maskfile: string, file name of mask, mask file supported: .npy, .tif file, ATTN: mask in .npy form @@ -102,8 +103,9 @@ def dynamicMask( darkpixelmask=None, avgmask=None, ): - """Create a dynamic mask according to image array. This mask - changes for different images. + """Create a dynamic mask according to image array. + + This mask changes for different images. :param pic: 2d array, image array to be processed :param dymask: 2d array, mask array used in average mask @@ -116,7 +118,6 @@ def dynamicMask( to the average intensity at the similar diffraction angle :return: 2d array of boolean, 1 stands for masked pixel """ - brightpixelmask = ( self.brightpixelmask if brightpixelmask is None @@ -232,10 +233,11 @@ def brightPixelMask(self, pic, size=None, r=None): return ind def undersample(self, undersamplerate): - """A special mask used for undesampling image. It will create a - mask that discard (total number*(1-undersamplerate)) pixels - :param undersamplerate: float, 0~1, ratio of pixels to keep. + """A special mask used for undesampling image. + It will create a mask that discard (total + number*(1-undersamplerate)) pixels + :param undersamplerate: float, 0~1, ratio of pixels to keep. :return: 2d array of boolean, 1 stands for masked pixel """ mask = ( @@ -256,10 +258,11 @@ def flipImage(self, pic): return pic def saveMask(self, filename, pic=None, addmask=None): - """Generate a mask according to the addmask and pic. save it to - .npy. 1 stands for masked pixel the mask has same order as the - pic, which means if the pic is flipped, the mask is flipped - (when pic is loaded though loadimage, it is flipped) + """Generate a mask according to the addmask and pic. + + save it to .npy. 1 stands for masked pixel the mask has same + order as the pic, which means if the pic is flipped, the mask is + flipped (when pic is loaded though loadimage, it is flipped) :param filename: str, filename of mask file to be save :param pic: 2d array, image array diff --git a/src/diffpy/srxplanar/saveresults.py b/src/diffpy/srxplanar/saveresults.py index 55f3e59..88cb5b4 100644 --- a/src/diffpy/srxplanar/saveresults.py +++ b/src/diffpy/srxplanar/saveresults.py @@ -114,12 +114,13 @@ def saveGSAS(self, xrd, filename): def writeGSASStr(name, mode, tth, iobs, esd=None): - """Return string of integrated intensities in GSAS format. :param - mode: string, gsas file type, could be 'std', 'esd', 'fxye' (gsas - format) :param tth: ndarray, two theta angle :param iobs: ndarray, - Xrd intensity :param esd: ndarray, optional error value of - intensity. + """Return string of integrated intensities in GSAS format. + :param mode: string, gsas file type, could be 'std', 'esd', 'fxye' + (gsas format) + :param tth: ndarray, two theta angle + :param iobs: ndarray, Xrd intensity + :param esd: ndarray, optional error value of intensity. :return: string, a string to be saved to file """ maxintensity = 999999 diff --git a/src/diffpy/srxplanar/selfcalibrate.py b/src/diffpy/srxplanar/selfcalibrate.py index 136aedc..53e6a7e 100644 --- a/src/diffpy/srxplanar/selfcalibrate.py +++ b/src/diffpy/srxplanar/selfcalibrate.py @@ -356,7 +356,6 @@ def selfCalibrate( :return: list, refined parameter """ - # lineCalibrate(srx, image) p = [] diff --git a/src/diffpy/srxplanar/srxplanar.py b/src/diffpy/srxplanar/srxplanar.py index 261766c..68d41e8 100644 --- a/src/diffpy/srxplanar/srxplanar.py +++ b/src/diffpy/srxplanar/srxplanar.py @@ -208,7 +208,6 @@ def integrate( in [tth or q, intensity, (uncertainty)]. rv['filename'] is the name of file to save to disk """ - rv = {} self.pic = self._getPic(image, flip, correction) diff --git a/src/diffpy/srxplanar/srxplanar_app.py b/src/diffpy/srxplanar/srxplanar_app.py index 0d48c30..f077116 100644 --- a/src/diffpy/srxplanar/srxplanar_app.py +++ b/src/diffpy/srxplanar/srxplanar_app.py @@ -7,8 +7,9 @@ def main(): parser = argparse.ArgumentParser( prog="diffpy.srxplanar", description=( - "2D diffraction image integration using non " - "splitting pixel algorithm\n\nFor more information, visit: " + "2D diffraction image integration using non splitting " + "pixel algorithm\n\n" + "For more information, visit: " "https://github.com/diffpy/diffpy.srxplanar/" ), formatter_class=argparse.RawDescriptionHelpFormatter, diff --git a/src/diffpy/srxplanar/srxplanarconfig.py b/src/diffpy/srxplanar/srxplanarconfig.py index b616587..5ba948d 100644 --- a/src/diffpy/srxplanar/srxplanarconfig.py +++ b/src/diffpy/srxplanar/srxplanarconfig.py @@ -526,7 +526,6 @@ def _preInit(self, **kwargs): add degree/rad delegation for rotation, tilt, tthstep, tthmax """ - for name in ["rotation", "tilt", "tthstep", "tthmax"]: setattr(self.__class__, name, _configPropertyRad(name + "d")) # cls._configlist['Experiment'].extend([ @@ -568,7 +567,6 @@ def _postUpdateConfig(self, **kwargs): :param kwargs: optional kwargs """ - if (self.createconfig != "") and (self.createconfig is not None): self.nocalculation = True if (self.createconfigfull != "") and ( diff --git a/src/diffpy/srxplanar/tifffile.py b/src/diffpy/srxplanar/tifffile.py index 3a42f13..91c04a6 100644 --- a/src/diffpy/srxplanar/tifffile.py +++ b/src/diffpy/srxplanar/tifffile.py @@ -2283,7 +2283,6 @@ def read_nih_image_header(fh, byteorder, dtype, count): def imagej_metadata(data, bytecounts, byteorder): """Return dict from ImageJ meta data tag value.""" - _str = str if sys.version_info[0] < 3 else lambda x: str(x, "cp1252") def read_string(data, byteorder): @@ -2776,11 +2775,12 @@ def datetime_from_timestamp(n, epoch=datetime.datetime.fromordinal(693594)): def test_tifffile(directory="testimages", verbose=True): - """Read all images in directory. Print error message on failure. + """Read all images in directory. - Examples - -------- - >>> test_tifffile(verbose=False) + Print error message on failure. + Examples + -------- + >>> test_tifffile(verbose=False) """ successful = 0 failed = 0 diff --git a/src/diffpy/srxplanar/version.py b/src/diffpy/srxplanar/version.py index 0cdb9ed..a508b52 100644 --- a/src/diffpy/srxplanar/version.py +++ b/src/diffpy/srxplanar/version.py @@ -2,12 +2,13 @@ ############################################################################## # # (c) 2010-2025 The Trustees of Columbia University in the City of New York. +# (c) 2026 Billinge Group Members and The DiffPy Team. # All rights reserved. # -# File coded by: Xiaohao Yang, Simon Billinge, Billinge Group members. +# File coded by: Xiaohao Yang and Billinge Group members. # # See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.srxplanar/graphs/contributors +# https://github.com/diffpy/diffpy.srxplanar/graphs/contributors # noqa: E501 # # See LICENSE.rst for license information. # diff --git a/tests/conftest.py b/tests/conftest.py index ca56905..ea2f144 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -13,10 +13,7 @@ def user_filesystem(tmp_path): for dir in (cwd_dir, home_dir, test_dir): dir.mkdir(parents=True, exist_ok=True) - home_config_data = { - "username": "home_username", - "email": "home@email.com", - } + home_config_data = {"username": "home_username", "email": "home@email.com"} with open(home_dir / "diffpyconfig.json", "w") as f: json.dump(home_config_data, f) diff --git a/tests/test_version.py b/tests/test_version.py index 999ff52..dbd2697 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,6 +1,6 @@ """Unit tests for __version__.py.""" -import diffpy.srxplanar +import diffpy.srxplanar # noqa def test_package_version():