diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml index baac1aeb..5e4b8fec 100644 --- a/.github/workflows/tests-on-pr.yml +++ b/.github/workflows/tests-on-pr.yml @@ -1,15 +1,12 @@ name: Tests on PR on: - push: - branches: - - main pull_request: workflow_dispatch: jobs: tests-on-pr: - uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 + uses: scikit-package/release-scripts/.github/workflows/_tests-on-pr.yml@v0 with: project: diffpy.utils c_extension: false diff --git a/.gitignore b/.gitignore index a25212ea..099e2948 100644 --- a/.gitignore +++ b/.gitignore @@ -10,6 +10,7 @@ __pycache__/ .Python env/ build/ +_build/ develop-eggs/ dist/ downloads/ @@ -90,10 +91,3 @@ target/ # Ipython Notebook .ipynb_checkpoints - -# version information -setup.cfg -/src/diffpy/*/version.cfg - -# Rever -rever/ diff --git a/news/setup-CI.rst b/news/setup-CI.rst new file mode 100644 index 00000000..527f9f87 --- /dev/null +++ b/news/setup-CI.rst @@ -0,0 +1,24 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* Support ``scikit-package`` Level 5 standard for file structure and CI workflow (https://scikit-package.github.io/scikit-package/). + + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 10a6f890..a0c525c8 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -6,13 +6,13 @@ build-backend = "setuptools.build_meta" name = "diffpy.utils" dynamic=['version', 'dependencies'] authors = [ - { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, + { name="Simon Billinge", email="sb2896@columbia.edu" }, ] maintainers = [ - { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, + { name="Simon Billinge", email="sb2896@columbia.edu" }, ] description = "General utilities for analyzing diffraction data" -keywords = ["text data parsers", "wx grid", "diffraction objects"] +keywords = ['text data parsers', 'wx grid', 'diffraction objects'] readme = "README.rst" requires-python = ">=3.11, <3.14" classifiers = [ @@ -20,14 +20,14 @@ classifiers = [ 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', - 'License :: Free To Use But Restricted', + 'License :: OSI Approved :: BSD License', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: Unix', 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', - 'Programming Language :: Python :: 3.13', + 'Programming Language :: Python :: 3.13', 'Topic :: Scientific/Engineering :: Physics', 'Topic :: Scientific/Engineering :: Chemistry', ] diff --git a/requirements/build.txt b/requirements/build.txt deleted file mode 100644 index e69de29b..00000000 diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index 00208e23..d2a03b94 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -1,11 +1,7 @@ #!/usr/bin/env python ############################################################################## # -# diffpy by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# (c) 2024 The Trustees of Columbia University in the City of New York. +# (c) 2025 The Trustees of Columbia University in the City of New York. # All rights reserved. # # File coded by: Billinge Group members and community contributors. @@ -16,14 +12,3 @@ # See LICENSE.rst for license information. # ############################################################################## -"""diffpy - tools for structure analysis by diffraction. - -Blank namespace package. -""" - - -from pkgutil import extend_path - -__path__ = extend_path(__path__, __name__) - -# End of file diff --git a/src/diffpy/utils/__init__.py b/src/diffpy/utils/__init__.py index 12f4a49d..ad966a6d 100644 --- a/src/diffpy/utils/__init__.py +++ b/src/diffpy/utils/__init__.py @@ -1,10 +1,10 @@ #!/usr/bin/env python ############################################################################## # -# (c) 2024 The Trustees of Columbia University in the City of New York. +# (c) 2025 The Trustees of Columbia University in the City of New York. # All rights reserved. # -# File coded by: Billinge Group members and community contributors. +# File coded by: Simon Billinge, Billinge Group members. # # See GitHub contributions for a more detailed list of contributors. # https://github.com/diffpy/diffpy.utils/graphs/contributors @@ -12,10 +12,12 @@ # See LICENSE.rst for license information. # ############################################################################## -"""Shared utilities for diffpy packages.""" +"""General utilities for analyzing diffraction data.""" # package version -from diffpy.utils.version import __version__ +from diffpy.utils.version import __version__ # noqa # silence the pyflakes syntax checker assert __version__ or True + +# End of file diff --git a/src/diffpy/utils/version.py b/src/diffpy/utils/version.py index e74c47bd..c767ea96 100644 --- a/src/diffpy/utils/version.py +++ b/src/diffpy/utils/version.py @@ -1,13 +1,13 @@ #!/usr/bin/env python ############################################################################## # -# (c) 2024 The Trustees of Columbia University in the City of New York. +# (c) 2025 The Trustees of Columbia University in the City of New York. # All rights reserved. # -# File coded by: Billinge Group members and community contributors. +# File coded by: Simon Billinge, Billinge Group members. # # See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.utils/graphs/contributors +# https://github.com/diffpy/diffpy.utils/graphs/contributors # noqa: E501 # # See LICENSE.rst for license information. # @@ -21,3 +21,5 @@ from importlib.metadata import version __version__ = version("diffpy.utils") + +# End of file diff --git a/tests/conftest.py b/tests/conftest.py index fcccb186..e3b63139 100644 --- a/tests/conftest.py +++ b/tests/conftest.py @@ -1,112 +1,19 @@ import json from pathlib import Path -import numpy as np import pytest -from diffpy.utils.diffraction_objects import DiffractionObject - @pytest.fixture def user_filesystem(tmp_path): base_dir = Path(tmp_path) home_dir = base_dir / "home_dir" home_dir.mkdir(parents=True, exist_ok=True) - cwd_dir = home_dir / "cwd_dir" + cwd_dir = base_dir / "cwd_dir" cwd_dir.mkdir(parents=True, exist_ok=True) - home_config_data = { - "owner_name": "home_ownername", - "owner_email": "home@email.com", - "owner_orcid": "home_orcid", - } + + 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) - yield home_dir, cwd_dir - - -@pytest.fixture -def datafile(): - """Fixture to dynamically load any test file.""" - base_path = Path(__file__).parent / "testdata" # Adjusted base path - - def _load(filename): - return base_path / filename - - return _load - - -@pytest.fixture -def do_minimal(): - # Create an instance of DiffractionObject with empty xarray and yarray - # values, and a non-empty wavelength - return DiffractionObject( - xarray=np.empty(0), yarray=np.empty(0), xtype="tth", wavelength=1.54 - ) - - -@pytest.fixture -def do_minimal_tth(): - # Create an instance of DiffractionObject with non-empty xarray, yarray, - # and wavelength values - return DiffractionObject( - wavelength=2 * np.pi, - xarray=np.array([30, 60]), - yarray=np.array([1, 2]), - xtype="tth", - ) - -@pytest.fixture -def do_minimal_d(): - # Create an instance of DiffractionObject with non-empty xarray, yarray, - # and wavelength values - return DiffractionObject( - wavelength=1.54, - xarray=np.array([1, 2]), - yarray=np.array([1, 2]), - xtype="d", - ) - - -@pytest.fixture -def wavelength_warning_msg(): - return ( - "No wavelength has been specified. You can continue to use the " - "DiffractionObject, but some of its powerful features will not be " - "available. " - "To specify a wavelength, if you have " - "do = DiffractionObject(xarray, yarray, 'tth'), " - "you may set do.wavelength = 1.54 for a wavelength of 1.54 angstroms." - ) - - -@pytest.fixture -def invalid_q_or_d_or_wavelength_error_msg(): - return ( - "The supplied input array and wavelength will result in an " - "impossible two-theta. " - "Please check these values and re-instantiate the DiffractionObject " - "with correct values." - ) - - -@pytest.fixture -def invalid_add_type_error_msg(): - return ( - "You may only add a DiffractionObject with another DiffractionObject " - "or a scalar value. " - "Please rerun by adding another DiffractionObject instance or a " - "scalar value. " - "e.g., my_do_1 + my_do_2 or my_do + 10 or 10 + my_do" - ) - - -@pytest.fixture -def x_values_not_equal_error_msg(): - return ( - "The two objects have different values in x arrays " - "(my_do.all_arrays[:, [1, 2, 3]]). " - "Please ensure the x values of the two objects are identical " - "by re-instantiating the DiffractionObject with the correct x value " - "inputs." - ) + yield tmp_path diff --git a/tests/test_version.py b/tests/test_version.py index 4152a197..9cf78e46 100644 --- a/tests/test_version.py +++ b/tests/test_version.py @@ -1,6 +1,6 @@ """Unit tests for __version__.py.""" -import diffpy.utils +import diffpy.utils # noqa def test_package_version():