diff --git a/.gitarchive.cfg b/.gitarchive.cfg deleted file mode 100644 index 95e1448c..00000000 --- a/.gitarchive.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[DEFAULT] -commit = $Format:%H$ -date = $Format:%ci$ -timestamp = $Format:%ct$ -refnames = $Format:%D$ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 0caa8f9f..00000000 --- a/.gitattributes +++ /dev/null @@ -1 +0,0 @@ -diffpy.pdfgui/_version.py export-subst diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 00000000..3982a783 --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,12 @@ +name: Check for News + +on: + pull_request_target: + branches: + - main + +jobs: + build: + uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 + with: + project: diffpy.pdfgui diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml deleted file mode 100644 index 465d42c7..00000000 --- a/.github/workflows/codecov.yml +++ /dev/null @@ -1,62 +0,0 @@ -name: Gather coverage report and upload to codecov - -on: - push: - branches: - - main - release: - types: - - prereleased - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - coverage: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install Xvfb - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - export DISPLAY=:99 - coverage run -m pytest -vv -s - coverage report -m - codecov - - - name: Upload coverage to Codecov - uses: codecov/codecov-action@v4 - env: - CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml deleted file mode 100644 index 624a7a66..00000000 --- a/.github/workflows/docs.yml +++ /dev/null @@ -1,48 +0,0 @@ -name: Build and Deploy Documentation - -on: - release: - types: - - published - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - docs: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: build - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and build requirements - run: | - conda install --file requirements/build.txt - conda install --file requirements/run.txt - conda install --file requirements/docs.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: build documents - run: make -C doc html - - - name: Deploy - uses: peaceiris/actions-gh-pages@v4 - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/build/html diff --git a/.github/workflows/main.yml b/.github/workflows/main.yml deleted file mode 100644 index 1722ee0f..00000000 --- a/.github/workflows/main.yml +++ /dev/null @@ -1,52 +0,0 @@ -name: Test - -on: - push: - branches: - - main - pull_request: - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - validate: - runs-on: ubuntu-latest - steps: - - name: Check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install Xvfb - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - export DISPLAY=:99 - python -m pytest diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml new file mode 100644 index 00000000..23dd9d8f --- /dev/null +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +jobs: + coverage: + uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false + headless: true + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/matrix.yml b/.github/workflows/matrix.yml deleted file mode 100644 index c2d3446c..00000000 --- a/.github/workflows/matrix.yml +++ /dev/null @@ -1,73 +0,0 @@ -name: Matrix test - -on: - push: - branches: - - main - workflow_dispatch: - -defaults: - run: - shell: bash -l {0} - -jobs: - test: - name: Python ${{ matrix.python-version }}, OS ${{ matrix.os }} - runs-on: ${{ matrix.os }} - strategy: - matrix: - python-version: ['3.10', '3.11', '3.12'] - os: ["macos-latest", "ubuntu-latest", "windows-latest"] - steps: - - name: check out diffpy.pdfgui - uses: actions/checkout@v4 - - - name: Initialize miniconda - uses: conda-incubator/setup-miniconda@v3 - with: - activate-environment: test - auto-update-conda: true - environment-file: environment.yml - python-version: ${{ matrix.python-version }} - auto-activate-base: false - - - name: Conda config - run: >- - conda config --set always_yes yes - --set changeps1 no - - - name: Install diffpy.pdfgui and requirements - run: | - conda install --file requirements/run.txt - conda install --file requirements/test.txt - python -m pip install -r requirements/pip.txt - python -m pip install . --no-deps - - - name: Install latest diffpy.pdffit2 for Mac - if: runner.os == 'macos-latest' - run: | - conda uninstall diffpy.pdffit2 - brew install gsl - pip install diffpy.pdffit2==1.4.4rc1 - - - name: Install Xvfb - if: runner.os == 'Linux' - run: sudo apt-get install -y xvfb - - - name: Start Xvfb - if: runner.os == 'Linux' - run: | - export DISPLAY=:99 - Xvfb :99 -screen 0 1024x768x16 & - - - name: Validate diffpy.pdfgui - run: | - if [ "$RUNNER_OS" == "Linux" ]; then - export DISPLAY=:99 - fi - python -m pytest - - - name: Display Python and Conda info - run: | - python --version - conda info diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml new file mode 100644 index 00000000..51215241 --- /dev/null +++ b/.github/workflows/publish-docs-on-release.yml @@ -0,0 +1,14 @@ +name: Build and Deploy Docs + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + docs: + uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false diff --git a/.github/workflows/tests-on-pr.yml b/.github/workflows/tests-on-pr.yml new file mode 100644 index 00000000..a5fb414f --- /dev/null +++ b/.github/workflows/tests-on-pr.yml @@ -0,0 +1,16 @@ +name: Tests on PR + +on: + push: + branches: + - main + pull_request: + workflow_dispatch: + +jobs: + validate: + uses: Billingegroup/release-scripts/.github/workflows/_tests-on-pr.yml@v0 + with: + project: diffpy.pdfgui + c_extension: false + headless: true diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml index c4588061..3070e199 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -16,7 +16,10 @@ repos: - id: check-yaml - id: end-of-file-fixer - id: trailing-whitespace - exclude: '\.(rst|txt)$' + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.4.2 hooks: diff --git a/AUTHORS.rst b/AUTHORS.rst index 99b148ea..739f2f4b 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -15,17 +15,17 @@ This code was developed as part of the DiffPy project to create python modules for structure investigations from diffraction data. The main contributors to this package were - Chris Farrow, - Jiwu Liu, - Pavol Juhas, + Chris Farrow, + Jiwu Liu, + Pavol Juhas, Dmitriy Bryndin Other current and former contributors of the DiffPy project include - Simon Billinge, - Chris Farrow, - Emil Bozin, - Wenduo Zhou, + Simon Billinge, + Chris Farrow, + Emil Bozin, + Wenduo Zhou, Peng Tian The DiffPy team is part of the Billinge Group at Columbia University in New York, diff --git a/MANIFEST.in b/MANIFEST.in index 3716e8cb..f1a78eec 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,21 +1,12 @@ -recursive-include src * -recursive-include doc * -recursive-exclude * __pycache__ -recursive-exclude * *.py[co] -exclude doc/manual/images/*.pdf -recursive-exclude doc/manual Makefile *.py *.texinfo -recursive-exclude doc/manual *.aux *.cp *.cps *.err *.log *.toc *.vr *.vrs -recursive-include icons *.png *.ico -recursive-exclude icons *.m *.xcf -global-exclude .gitattributes .gitignore .gitarchive.cfg -global-exclude .DS_Store +graft src +graft tests +graft requirements -include AUTHORS.rst -include LICENSE.rst -include README.rst -include requirements.txt +include AUTHORS.rst LICENSE*.rst README.rst -include diffpy.pdfgui/_version.py - -# If including data files in the package, add them like: -# include path/to/data_file +# Exclude all bytecode files and __pycache__ directories +global-exclude *.py[cod] # Exclude all .pyc, .pyo, and .pyd files. +global-exclude .DS_Store # Exclude Mac filesystem artifacts. +global-exclude __pycache__ # Exclude Python cache directories. +global-exclude .git* # Exclude git files and directories. +global-exclude .idea # Exclude PyCharm project settings. diff --git a/README.rst b/README.rst index 3f1a9a10..74ca65ab 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.pdfgui/actions/workflows/main.yml/badge.svg - :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/main.yml +.. |CI| image:: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.pdfgui/actions/workflows/matrix-and-codecov-on-merge-to-main.yml .. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.pdfgui/branch/main/graph/badge.svg :target: https://codecov.io/gh/diffpy/diffpy.pdfgui @@ -38,11 +38,11 @@ Graphical user interface program for structure refinements to atomic pair distribution function. -For users who do not have the expertise or necessity for command -line analysis, PDFgui is a convenient and easy to use graphical front -end for the PDFfit2 refinement program. It is capable of full-profile -fitting of the atomic pair distribution function (PDF) derived from x-ray -or neutron diffraction data and comes with built in graphical and structure +For users who do not have the expertise or necessity for command +line analysis, PDFgui is a convenient and easy to use graphical front +end for the PDFfit2 refinement program. It is capable of full-profile +fitting of the atomic pair distribution function (PDF) derived from x-ray +or neutron diffraction data and comes with built in graphical and structure visualization capabilities. PDFgui is a friendly interface to the PDFfit2 refinement engine, with many @@ -50,18 +50,18 @@ powerful extensions. To get started, please open the manual from the help menu and follow the tutorial instructions. A detailed description is available in `this paper `_. -For more information about diffpy.pdfgui, please consult our +For more information about diffpy.pdfgui, please consult our `online documentation `_. Citation -------- -If you use diffpy.pdfgui in a scientific publication, we would like you to +If you use diffpy.pdfgui in a scientific publication, we would like you to cite this package as - C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, - J Bloch, Th Proffen and S J L Billinge, PDFfit2 and PDFgui: - computer programs for studying nanostructure in crystals, J. Phys.: + C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, + J Bloch, Th Proffen and S J L Billinge, PDFfit2 and PDFgui: + computer programs for studying nanostructure in crystals, J. Phys.: Condens. Matter 19 (2007) 335219. doi:10.1088/0953-8984/19/33/335219 Installation @@ -87,31 +87,22 @@ Then, to fully install ``diffpy.pdfgui`` in our active environment, run :: Another option is to use ``pip`` to download and install the latest release from `Python Package Index `_. -To install using ``pip`` into your ``diffpy.pdfgui_env`` environment, we will also have to -install dependencies :: - - pip install -r https://raw.githubusercontent.com/diffpy/diffpy.pdfgui/main/requirements/run.txt - -and then install the package :: +To install using ``pip`` into your ``diffpy.pdfgui_env`` environment, type :: pip install diffpy.pdfgui If you prefer to install from sources, after installing the dependencies, obtain the source archive from -`GitHub `_. Once installed, ``cd`` into your ``diffpy.pdfgui`` -directory and run the following :: +`GitHub `_. Once installed, ``cd`` into your ``diffpy.pdfgui`` directory +and run the following :: pip install . Support and Contribute ---------------------- -`Diffpy user group `_ is the discussion forum for general -questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community -by joining the Google group. The diffpy.pdfgui project welcomes your expertise and enthusiasm! +`Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.pdfgui. Please join the diffpy.pdfgui users community by joining the Google group. The diffpy.pdfgui 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 `_. You can also post it to the `Diffpy user group `_. Feel free to fork the project and contribute. To install diffpy.pdfgui in a development mode, with its sources being directly used by Python @@ -139,5 +130,4 @@ Before contribuing, please read our `Code of Conduct `_ or email Prof. Simon Billinge -at sb2896@columbia.edu. +For more information on diffpy.pdfgui please visit the project `web-page `_ or email Prof. Simon Billinge at sb2896@columbia.edu. diff --git a/devutils/makesdist b/devutils/makesdist deleted file mode 100755 index dccfaa99..00000000 --- a/devutils/makesdist +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -"""Create source distribution tar.gz archive, where each file belongs -to a root user and modification time is set to the git commit time. -""" - -import glob -import gzip -import os -import subprocess -import sys -import tarfile - -from setup import FALLBACK_VERSION, versiondata - -BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) -sys.path.insert(0, BASEDIR) - -timestamp = versiondata.getint("DEFAULT", "timestamp") - -vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0" -emsg = "Invalid FALLBACK_VERSION. Expected %r got %r." -assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION) - - -def inform(s): - sys.stdout.write(s) - sys.stdout.flush() - return - - -inform('Run "setup.py sdist --formats=tar" ') -cmd_sdist = [sys.executable] + "setup.py sdist --formats=tar".split() -ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, "w")) -if ec: - sys.exit(ec) -inform("[done]\n") - -tarname = max(glob.glob(BASEDIR + "/dist/*.tar"), key=os.path.getmtime) - -tfin = tarfile.open(tarname) -fpout = gzip.GzipFile(tarname + ".gz", "w", mtime=0) -tfout = tarfile.open(fileobj=fpout, mode="w") - - -def fixtarinfo(tinfo): - tinfo.uid = tinfo.gid = 0 - tinfo.uname = tinfo.gname = "root" - tinfo.mtime = timestamp - tinfo.mode &= ~0o022 - return tinfo - - -inform("Filter %s --> %s.gz " % (2 * (os.path.basename(tarname),))) -for ti in tfin: - tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti)) - -tfin.close() -os.remove(tarname) -inform("[done]\n") diff --git a/doc/make.bat b/doc/make.bat index 2be83069..ac53d5bd 100644 --- a/doc/make.bat +++ b/doc/make.bat @@ -1,36 +1,36 @@ -@ECHO OFF - -pushd %~dp0 - -REM Command file for Sphinx documentation - -if "%SPHINXBUILD%" == "" ( - set SPHINXBUILD=sphinx-build -) -set SOURCEDIR=source -set BUILDDIR=build -set SPHINXPROJ=PackagingScientificPython - -if "%1" == "" goto help - -%SPHINXBUILD% >NUL 2>NUL -if errorlevel 9009 ( - echo. - echo.The 'sphinx-build' command was not found. Make sure you have Sphinx - echo.installed, then set the SPHINXBUILD environment variable to point - echo.to the full path of the 'sphinx-build' executable. Alternatively you - echo.may add the Sphinx directory to PATH. - echo. - echo.If you don't have Sphinx installed, grab it from - echo.http://sphinx-doc.org/ - exit /b 1 -) - -%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% -goto end - -:help -%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% - -:end -popd +@ECHO OFF + +pushd %~dp0 + +REM Command file for Sphinx documentation + +if "%SPHINXBUILD%" == "" ( + set SPHINXBUILD=sphinx-build +) +set SOURCEDIR=source +set BUILDDIR=build +set SPHINXPROJ=PackagingScientificPython + +if "%1" == "" goto help + +%SPHINXBUILD% >NUL 2>NUL +if errorlevel 9009 ( + echo. + echo.The 'sphinx-build' command was not found. Make sure you have Sphinx + echo.installed, then set the SPHINXBUILD environment variable to point + echo.to the full path of the 'sphinx-build' executable. Alternatively you + echo.may add the Sphinx directory to PATH. + echo. + echo.If you don't have Sphinx installed, grab it from + echo.http://sphinx-doc.org/ + exit /b 1 +) + +%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% +goto end + +:help +%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% + +:end +popd diff --git a/doc/source/api/diffpy.pdfgui.icons.rst b/doc/source/api/diffpy.pdfgui.icons.rst new file mode 100644 index 00000000..c953a711 --- /dev/null +++ b/doc/source/api/diffpy.pdfgui.icons.rst @@ -0,0 +1,9 @@ +:tocdepth: -1 + +diffpy.pdfgui.icons package +=========================== + +.. automodule:: diffpy.pdfgui.icons + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/api/diffpy.pdfgui.rst b/doc/source/api/diffpy.pdfgui.rst index eaf4bd3f..ab800cde 100644 --- a/doc/source/api/diffpy.pdfgui.rst +++ b/doc/source/api/diffpy.pdfgui.rst @@ -14,6 +14,7 @@ Subpackages .. toctree:: :titlesonly: + diffpy.pdfgui.icons diffpy.pdfgui.gui diffpy.pdfgui.applications diffpy.pdfgui.control diff --git a/doc/source/index.rst b/doc/source/index.rst index 08740bd2..6d042abe 100644 --- a/doc/source/index.rst +++ b/doc/source/index.rst @@ -9,11 +9,11 @@ diffpy.pdfgui - GUI for PDF simulation and structure refinement. | Software version |release| | Last updated |today| -For users who do not have the expertise or necessity for command -line analysis, PDFgui is a convenient and easy to use graphical front -end for the PDFfit2 refinement program. It is capable of full-profile -fitting of the atomic pair distribution function (PDF) derived from x-ray -or neutron diffraction data and comes with built in graphical and structure +For users who do not have the expertise or necessity for command +line analysis, PDFgui is a convenient and easy to use graphical front +end for the PDFfit2 refinement program. It is capable of full-profile +fitting of the atomic pair distribution function (PDF) derived from x-ray +or neutron diffraction data and comes with built in graphical and structure visualization capabilities. PDFgui is a friendly interface to the PDFfit2 refinement engine, with many @@ -32,17 +32,17 @@ and do not necessarily reflect the views of the NSF. The main contributors to this package were - Chris Farrow, - Jiwu Liu, - Pavol Juhas, + Chris Farrow, + Jiwu Liu, + Pavol Juhas, Dmitriy Bryndin Other current and former contributors of the DiffPy project include - Simon Billinge, - Chris Farrow, - Emil Bozin, - Wenduo Zhou, + Simon Billinge, + Chris Farrow, + Emil Bozin, + Wenduo Zhou, Peng Tian The DiffPy team is part of the Billinge Group at Columbia University in New York, @@ -55,13 +55,13 @@ https://github.com/diffpy/diffpy.pdfgui/graphs/contributors. Reference ========= -If you use this program for a scientific research that leads to publication, -we ask that you acknowledge use of the program by citing the following paper +If you use this program for a scientific research that leads to publication, +we ask that you acknowledge use of the program by citing the following paper in your publication: - C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, - J Bloch, Th Proffen and S J L Billinge, `PDFfit2 and PDFgui: - computer programs for studying nanostructure in crystals `_, + C L Farrow, P Juhas, J W Liu, D Bryndin, E S Božin, + J Bloch, Th Proffen and S J L Billinge, `PDFfit2 and PDFgui: + computer programs for studying nanostructure in crystals `_, J. Phys.: Condens. Matter 19 (2007) 335219. ============ @@ -75,9 +75,9 @@ file included with the distribution. Tutorial ======== -The tutorial for the package can be found here: +The tutorial for the package can be found here: -.. toctree:: +.. toctree:: tutorial diff --git a/pyproject.toml b/pyproject.toml index f1926b11..8f24911f 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,10 +1,10 @@ [build-system] -requires = ["setuptools>=62.0", "setuptools-git-versioning<2"] +requires = ["setuptools>=62.0", "setuptools-git-versioning>=2.0"] build-backend = "setuptools.build_meta" [project] name = "diffpy.pdfgui" -dynamic=['version'] +dynamic=['version', 'dependencies'] authors = [ { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, ] @@ -47,9 +47,12 @@ dirty_template = "{tag}" [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) include = ["*"] # package names should match these glob patterns (["*"] by default) -exclude = ["diffpy.pdfgui.tests*"] # exclude packages matching these glob patterns (empty by default) +exclude = [] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) +[tool.setuptools.dynamic] +dependencies = {file = ["requirements/run.txt"]} + [tool.black] line-length = 115 include = '\.pyi?$' diff --git a/requirements/build.txt b/requirements/build.txt index f72d870d..e69de29b 100644 --- a/requirements/build.txt +++ b/requirements/build.txt @@ -1,2 +0,0 @@ -python -setuptools diff --git a/requirements/run.txt b/requirements/run.txt index a8d863e1..949c77f6 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,6 +1,6 @@ -numpy < 2.0.0 # Need to fix deprecations before 2.0.0 compat -wxpython -diffpy.pdffit2 -diffpy.structure -diffpy.utils -matplotlib-base +numpy < 2.0.0 +wxpython +diffpy.pdffit2 +diffpy.structure +diffpy.utils +matplotlib-base diff --git a/requirements/test.txt b/requirements/test.txt index 977a5764..eca1f580 100644 --- a/requirements/test.txt +++ b/requirements/test.txt @@ -1,6 +1,7 @@ flake8 -freezegun pytest +freezegun codecov coverage +pytest-cov pytest-env diff --git a/src/diffpy/pdfgui/__init__.py b/src/diffpy/pdfgui/__init__.py index c12002ca..e4d1d6c0 100644 --- a/src/diffpy/pdfgui/__init__.py +++ b/src/diffpy/pdfgui/__init__.py @@ -1,23 +1,21 @@ #!/usr/bin/env python ############################################################################## # -# diffpy.pdfgui by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2006 trustees of the Michigan State University. -# All rights reserved. +# (c) 2024 The Trustees of Columbia University in the City of New York. +# All rights reserved. # -# File coded by: Pavol Juhas +# File coded by: Billinge Group members and community contributors. # -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## -"""Constants: - __version__ -- full version of this PDFgui release -""" - +"""GUI for PDF simulation and structure refinement.""" +# package version from diffpy.pdfgui.version import __version__ # silence the pyflakes syntax checker diff --git a/src/diffpy/pdfgui/tests/__init__.py b/src/diffpy/pdfgui/tests/__init__.py deleted file mode 100644 index beb24343..00000000 --- a/src/diffpy/pdfgui/tests/__init__.py +++ /dev/null @@ -1,80 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# diffpy.pdfgui by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2012-2024 Trustees of the Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. -# -############################################################################## - -"""Unit tests for diffpy.pdfgui. -""" - -import unittest - - -def testsuite(pattern=""): - """Create a unit tests suite for diffpy.pdfgui package. - - Parameters - ---------- - pattern : str, optional - Regular expression pattern for selecting test cases. - Select all tests when empty. Ignore the pattern when - any of unit test modules fails to import. - - Returns - ------- - suite : `unittest.TestSuite` - The TestSuite object containing the matching tests. - """ - import re - from importlib.resources import files - from itertools import chain - from os.path import dirname - - loader = unittest.defaultTestLoader - thisdir = str(files(__name__)) - depth = __name__.count(".") + 1 - topdir = thisdir - for i in range(depth): - topdir = dirname(topdir) - suite_all = loader.discover(thisdir, top_level_dir=topdir) - # always filter the suite by pattern to test-cover the selection code. - suite = unittest.TestSuite() - rx = re.compile(pattern) - tsuites = list(chain.from_iterable(suite_all)) - tsok = all(isinstance(ts, unittest.TestSuite) for ts in tsuites) - if not tsok: # pragma: no cover - return suite_all - tcases = chain.from_iterable(tsuites) - for tc in tcases: - tcwords = tc.id().split(".") - shortname = ".".join(tcwords[-3:]) - if rx.search(shortname): - suite.addTest(tc) - # verify all tests are found for an empty pattern. - assert pattern or suite_all.countTestCases() == suite.countTestCases() - return suite - - -def test(): - """Execute all unit tests for the diffpy.pdfgui package. - - Returns - ------- - result : `unittest.TestResult` - """ - suite = testsuite() - runner = unittest.TextTestRunner() - result = runner.run(suite) - return result - - -# End of file diff --git a/src/diffpy/pdfgui/tests/debug.py b/src/diffpy/pdfgui/tests/debug.py deleted file mode 100644 index c26a68d2..00000000 --- a/src/diffpy/pdfgui/tests/debug.py +++ /dev/null @@ -1,36 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2016 Brookhaven Science Associates, Brookhaven National Laboratory. -# (c) 2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -""" -Convenience module for debugging the unit tests using - -python -m diffpy.pdfgui.tests.debug - -Exceptions raised by failed tests or other errors are not caught. -""" - - -if __name__ == "__main__": - import sys - - from diffpy.pdfgui.tests import testsuite - - pattern = sys.argv[1] if len(sys.argv) > 1 else "" - suite = testsuite(pattern) - suite.debug() - - -# End of file diff --git a/src/diffpy/pdfgui/tests/run.py b/src/diffpy/pdfgui/tests/run.py deleted file mode 100644 index 2184cda6..00000000 --- a/src/diffpy/pdfgui/tests/run.py +++ /dev/null @@ -1,38 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# (c) 2012-2024 The Trustees of Columbia University in the City of New York. -# All rights reserved. -# -# File coded by: Billinge Group members and community contributors. -# -# See GitHub contributions for a more detailed list of contributors. -# https://github.com/diffpy/diffpy.pdfgui/graphs/contributors -# -# See LICENSE.rst for license information. -# -############################################################################## - -"""Convenience module for executing all unit tests with - -python -m diffpy.pdfgui.tests.run -""" - - -if __name__ == "__main__": - import sys - - # show warnings by default - if not sys.warnoptions: - import os - import warnings - - warnings.simplefilter("default") - # also affect subprocesses - os.environ["PYTHONWARNINGS"] = "default" - from diffpy.pdfgui.tests import test - - # produce zero exit code for a successful test - sys.exit(not test().wasSuccessful()) - -# End of file diff --git a/src/diffpy/pdfgui/tests/conftest.py b/tests/conftest.py similarity index 100% rename from src/diffpy/pdfgui/tests/conftest.py rename to tests/conftest.py diff --git a/src/diffpy/pdfgui/tests/test_aboutdialog.py b/tests/test_aboutdialog.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_aboutdialog.py rename to tests/test_aboutdialog.py index 44078276..532bd2e8 100644 --- a/src/diffpy/pdfgui/tests/test_aboutdialog.py +++ b/tests/test_aboutdialog.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, overridewebbrowser from diffpy.pdfgui.gui import aboutdialog -from diffpy.pdfgui.tests.testutils import GUITestCase, overridewebbrowser # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_calculation.py b/tests/test_calculation.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_calculation.py rename to tests/test_calculation.py diff --git a/src/diffpy/pdfgui/tests/test_constraint.py b/tests/test_constraint.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_constraint.py rename to tests/test_constraint.py diff --git a/src/diffpy/pdfgui/tests/test_datasetpanels.py b/tests/test_datasetpanels.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_datasetpanels.py rename to tests/test_datasetpanels.py index 8d01dd40..ae83979b 100644 --- a/src/diffpy/pdfgui/tests/test_datasetpanels.py +++ b/tests/test_datasetpanels.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, tooltiptext from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, tooltiptext # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_dopingseriespanel.py b/tests/test_dopingseriespanel.py similarity index 95% rename from src/diffpy/pdfgui/tests/test_dopingseriespanel.py rename to tests/test_dopingseriespanel.py index c678c177..5dd06404 100644 --- a/src/diffpy/pdfgui/tests/test_dopingseriespanel.py +++ b/tests/test_dopingseriespanel.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, overridefiledialog from diffpy.pdfgui.gui.dopingseriespanel import DopingSeriesPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_extendedplotframe.py b/tests/test_extendedplotframe.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_extendedplotframe.py rename to tests/test_extendedplotframe.py index f97ad51a..4c7830bc 100644 --- a/src/diffpy/pdfgui/tests/test_extendedplotframe.py +++ b/tests/test_extendedplotframe.py @@ -21,11 +21,11 @@ import numpy import wx +from testutils import GUITestCase, overridefiledialog from diffpy.pdfgui.control.plotter import Plotter from diffpy.pdfgui.gui import extendedplotframe as epf from diffpy.pdfgui.gui.extendedplotframe import ExtendedPlotFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_fitdataset.py b/tests/test_fitdataset.py similarity index 99% rename from src/diffpy/pdfgui/tests/test_fitdataset.py rename to tests/test_fitdataset.py index d8d8aba6..994402cc 100644 --- a/src/diffpy/pdfgui/tests/test_fitdataset.py +++ b/tests/test_fitdataset.py @@ -20,10 +20,10 @@ import unittest import numpy +from testutils import datafile import diffpy.pdfgui.control.fitdataset as fds from diffpy.pdfgui.control.fitdataset import FitDataSet -from diffpy.pdfgui.tests.testutils import datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_fitstructure.py b/tests/test_fitstructure.py similarity index 99% rename from src/diffpy/pdfgui/tests/test_fitstructure.py rename to tests/test_fitstructure.py index f49caabb..090ed876 100644 --- a/src/diffpy/pdfgui/tests/test_fitstructure.py +++ b/tests/test_fitstructure.py @@ -6,11 +6,12 @@ import unittest +from testutils import datafile + from diffpy.pdfgui.control.constraint import Constraint from diffpy.pdfgui.control.controlerrors import ControlTypeError from diffpy.pdfgui.control.fitstructure import FitStructure from diffpy.pdfgui.control.pdfstructure import PDFStructure -from diffpy.pdfgui.tests.testutils import datafile from diffpy.structure import Structure # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_insertrowsdialog.py b/tests/test_insertrowsdialog.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_insertrowsdialog.py rename to tests/test_insertrowsdialog.py index 86baea93..7879582c 100644 --- a/src/diffpy/pdfgui/tests/test_insertrowsdialog.py +++ b/tests/test_insertrowsdialog.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase from diffpy.pdfgui.gui.insertrowsdialog import InsertRowsDialog -from diffpy.pdfgui.tests.testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_loadproject.py b/tests/test_loadproject.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_loadproject.py rename to tests/test_loadproject.py index 004d7e14..ac1f0443 100644 --- a/src/diffpy/pdfgui/tests/test_loadproject.py +++ b/tests/test_loadproject.py @@ -19,8 +19,9 @@ import unittest +from testutils import GUITestCase, datafile + from diffpy.pdfgui.control.controlerrors import ControlFileError -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile from diffpy.pdfgui.tui import LoadProject # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_mainframe.py b/tests/test_mainframe.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_mainframe.py rename to tests/test_mainframe.py index 32922c74..3a177a1f 100644 --- a/src/diffpy/pdfgui/tests/test_mainframe.py +++ b/tests/test_mainframe.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_parameter.py b/tests/test_parameter.py similarity index 97% rename from src/diffpy/pdfgui/tests/test_parameter.py rename to tests/test_parameter.py index 6559c42c..b0161a9f 100644 --- a/src/diffpy/pdfgui/tests/test_parameter.py +++ b/tests/test_parameter.py @@ -20,11 +20,11 @@ import unittest import wx +from testutils import GUITestCase, datafile from diffpy.pdfgui.control.controlerrors import ControlKeyError, ControlTypeError from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.mainframe import MainFrame -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_parameterspanel.py b/tests/test_parameterspanel.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_parameterspanel.py rename to tests/test_parameterspanel.py index a05574f2..ddb9a81b 100644 --- a/src/diffpy/pdfgui/tests/test_parameterspanel.py +++ b/tests/test_parameterspanel.py @@ -20,10 +20,10 @@ import unittest import wx.grid +from testutils import GUITestCase, clickcell from diffpy.pdfgui.control.parameter import Parameter from diffpy.pdfgui.gui.parameterspanel import ParametersPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, clickcell # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_pdfdataset.py b/tests/test_pdfdataset.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_pdfdataset.py rename to tests/test_pdfdataset.py index d3172865..be5fe080 100644 --- a/src/diffpy/pdfgui/tests/test_pdfdataset.py +++ b/tests/test_pdfdataset.py @@ -19,8 +19,9 @@ import unittest +from testutils import datafile + from diffpy.pdfgui.control.pdfdataset import PDFDataSet -from diffpy.pdfgui.tests.testutils import datafile ############################################################################## diff --git a/src/diffpy/pdfgui/tests/test_pdfguicontrol.py b/tests/test_pdfguicontrol.py similarity index 100% rename from src/diffpy/pdfgui/tests/test_pdfguicontrol.py rename to tests/test_pdfguicontrol.py diff --git a/src/diffpy/pdfgui/tests/test_pdfstructure.py b/tests/test_pdfstructure.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_pdfstructure.py rename to tests/test_pdfstructure.py index f4506ac8..2753328d 100644 --- a/src/diffpy/pdfgui/tests/test_pdfstructure.py +++ b/tests/test_pdfstructure.py @@ -6,9 +6,10 @@ import unittest +from testutils import datafile + from diffpy.pdfgui.control.controlerrors import ControlFileError, ControlKeyError from diffpy.pdfgui.control.pdfstructure import PDFStructure -from diffpy.pdfgui.tests.testutils import datafile # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py b/tests/test_phaseconfigurepanel.py similarity index 96% rename from src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py rename to tests/test_phaseconfigurepanel.py index acc01ec6..aae1a27d 100644 --- a/src/diffpy/pdfgui/tests/test_phaseconfigurepanel.py +++ b/tests/test_phaseconfigurepanel.py @@ -20,10 +20,10 @@ import unittest import wx +from testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext from diffpy.pdfgui.gui.mainframe import MainFrame from diffpy.pdfgui.gui.phaseconfigurepanel import PhaseConfigurePanel -from diffpy.pdfgui.tests.testutils import GUITestCase, clickcell, datafile, overrideclipboard, tooltiptext # ---------------------------------------------------------------------------- diff --git a/src/diffpy/pdfgui/tests/showphasenotebookpanel.py b/tests/test_showphasenotebookpanel.py similarity index 97% rename from src/diffpy/pdfgui/tests/showphasenotebookpanel.py rename to tests/test_showphasenotebookpanel.py index 71c3f0d3..5fec5d5e 100644 --- a/src/diffpy/pdfgui/tests/showphasenotebookpanel.py +++ b/tests/test_showphasenotebookpanel.py @@ -18,9 +18,9 @@ import wx +from testutils import datafile from diffpy.pdfgui.gui.phasenotebookpanel import PhaseNotebookPanel -from diffpy.pdfgui.tests.testutils import datafile from diffpy.pdfgui.tui import LoadProject diff --git a/src/diffpy/pdfgui/tests/test_structureviewer.py b/tests/test_structureviewer.py similarity index 98% rename from src/diffpy/pdfgui/tests/test_structureviewer.py rename to tests/test_structureviewer.py index d9205b63..02602087 100644 --- a/src/diffpy/pdfgui/tests/test_structureviewer.py +++ b/tests/test_structureviewer.py @@ -7,9 +7,10 @@ import os import unittest +from testutils import datafile + from diffpy.pdfgui.control.controlerrors import ControlConfigError from diffpy.pdfgui.control.structureviewer import StructureViewer, getStructureViewer -from diffpy.pdfgui.tests.testutils import datafile ############################################################################## diff --git a/src/diffpy/pdfgui/tests/test_temperatureseriespanel.py b/tests/test_temperatureseriespanel.py similarity index 95% rename from src/diffpy/pdfgui/tests/test_temperatureseriespanel.py rename to tests/test_temperatureseriespanel.py index 5835bff4..02ae7897 100644 --- a/src/diffpy/pdfgui/tests/test_temperatureseriespanel.py +++ b/tests/test_temperatureseriespanel.py @@ -20,9 +20,9 @@ import unittest import wx +from testutils import GUITestCase, datafile, overridefiledialog from diffpy.pdfgui.gui.temperatureseriespanel import TemperatureSeriesPanel -from diffpy.pdfgui.tests.testutils import GUITestCase, datafile, overridefiledialog # ---------------------------------------------------------------------------- diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 00000000..f7b12e23 --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +"""Unit tests for __version__.py +""" + +import diffpy.pdfgui + + +def test_package_version(): + """Ensure the package version is defined and not set to the initial placeholder.""" + assert hasattr(diffpy.pdfgui, "__version__") + assert diffpy.pdfgui.__version__ != "0.0.0" diff --git a/src/diffpy/pdfgui/tests/testdata/300K.gr b/tests/testdata/300K.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/300K.gr rename to tests/testdata/300K.gr diff --git a/src/diffpy/pdfgui/tests/testdata/550K.gr b/tests/testdata/550K.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/550K.gr rename to tests/testdata/550K.gr diff --git a/src/diffpy/pdfgui/tests/testdata/CdSe_bulk_wur.stru b/tests/testdata/CdSe_bulk_wur.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/CdSe_bulk_wur.stru rename to tests/testdata/CdSe_bulk_wur.stru diff --git a/src/diffpy/pdfgui/tests/testdata/LaMnO3.stru b/tests/testdata/LaMnO3.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/LaMnO3.stru rename to tests/testdata/LaMnO3.stru diff --git a/src/diffpy/pdfgui/tests/testdata/Ni.dat b/tests/testdata/Ni.dat similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni.dat rename to tests/testdata/Ni.dat diff --git a/src/diffpy/pdfgui/tests/testdata/Ni.stru b/tests/testdata/Ni.stru similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni.stru rename to tests/testdata/Ni.stru diff --git a/src/diffpy/pdfgui/tests/testdata/Ni_2-8.chi.gr b/tests/testdata/Ni_2-8.chi.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/Ni_2-8.chi.gr rename to tests/testdata/Ni_2-8.chi.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo.ddp b/tests/testdata/lcmo.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo.ddp rename to tests/testdata/lcmo.ddp diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_00.gr b/tests/testdata/lcmo_00.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_00.gr rename to tests/testdata/lcmo_00.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_20.gr b/tests/testdata/lcmo_20.gr similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_20.gr rename to tests/testdata/lcmo_20.gr diff --git a/src/diffpy/pdfgui/tests/testdata/lcmo_full.ddp b/tests/testdata/lcmo_full.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/lcmo_full.ddp rename to tests/testdata/lcmo_full.ddp diff --git a/src/diffpy/pdfgui/tests/testdata/ni.ddp b/tests/testdata/ni.ddp similarity index 100% rename from src/diffpy/pdfgui/tests/testdata/ni.ddp rename to tests/testdata/ni.ddp diff --git a/src/diffpy/pdfgui/tests/testutils.py b/tests/testutils.py similarity index 98% rename from src/diffpy/pdfgui/tests/testutils.py rename to tests/testutils.py index bf0e832f..6a887686 100644 --- a/src/diffpy/pdfgui/tests/testutils.py +++ b/tests/testutils.py @@ -29,10 +29,7 @@ def datafile(filename): - from importlib.resources import files - - rv = str(files(__name__).joinpath("testdata", filename)) - return rv + return "tests/testdata/" + filename @contextmanager