diff --git a/.codecov.yml b/.codecov.yml index 20ad66b..04dd651 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -1,10 +1,34 @@ -# show coverage in CI status, not as a comment. -comment: off +# codecov can find this file anywhere in the repo, so we don't need to clutter +# the root folder. +#comment: false + +codecov: + notify: + require_ci_to_pass: no + coverage: status: - project: - default: - target: auto patch: default: + target: '70' + if_no_uploads: error + if_not_found: success + if_ci_failed: failure + project: + default: false + library: target: auto + if_no_uploads: error + if_not_found: success + if_ci_failed: error + paths: '!*/tests/.*' + + tests: + target: 97.9% + paths: '*/tests/.*' + if_not_found: success + +flags: + tests: + paths: + - tests/ diff --git a/.coveragerc b/.coveragerc index b9313a4..9d60745 100644 --- a/.coveragerc +++ b/.coveragerc @@ -1,7 +1,6 @@ [run] source = - src - + diffpy.labpdfproc [report] omit = */python?.?/* diff --git a/.flake8 b/.flake8 index d5df4e6..2d2cb16 100644 --- a/.flake8 +++ b/.flake8 @@ -4,9 +4,8 @@ exclude = __pycache__, build, dist, - versioneer.py, - labpdfproc/_version.py, - doc/manual/source/conf.py + doc/source/conf.py max-line-length = 115 # Ignore some style 'errors' produced while formatting by 'black' -ignore = E203, W503 +# https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings +extend-ignore = E203 diff --git a/.gitattributes b/.gitattributes index 5532c6b..42030e8 100644 --- a/.gitattributes +++ b/.gitattributes @@ -1 +1 @@ -labpdfproc/_version.py export-subst +diffpy.labpdfproc/_version.py export-subst diff --git a/.github/workflows/docs.yml b/.github/workflows/docs.yml index 03dffa5..a4661f5 100644 --- a/.github/workflows/docs.yml +++ b/.github/workflows/docs.yml @@ -34,10 +34,10 @@ jobs: run: python -m pip install . --no-deps - name: build documents - run: make -C doc/manual html + run: make -C doc html - name: Deploy uses: peaceiris/actions-gh-pages@v3 with: github_token: ${{ secrets.GITHUB_TOKEN }} - publish_dir: ./doc/manual/build/html + publish_dir: ./doc/build/html diff --git a/.github/workflows/testing.yml b/.github/workflows/main.yml similarity index 90% rename from .github/workflows/testing.yml rename to .github/workflows/main.yml index c73ebb6..120f90f 100644 --- a/.github/workflows/testing.yml +++ b/.github/workflows/main.yml @@ -42,14 +42,13 @@ jobs: conda config --set always_yes yes --set changeps1 no conda config --add channels conda-forge conda activate test - conda install --file requirements/requirements.txt - conda install --file requirements/requirements-dev.txt + conda install --file requirements/run.txt + conda install --file requirements/test.txt pip install . - - name: Validate diffpy.labpdfproc shell: bash -l {0} run: | conda activate test - coverage run -m pytest -s + coverage run -m pytest -vv -s coverage report -m codecov diff --git a/.github/workflows/pre-commit.yml b/.github/workflows/pre-commit.yml index b04c86b..f2ff7e4 100644 --- a/.github/workflows/pre-commit.yml +++ b/.github/workflows/pre-commit.yml @@ -14,8 +14,6 @@ jobs: steps: - uses: actions/checkout@v3 - uses: actions/setup-python@v4 - - name: Make prevent_commit_to_main.sh executable - run: chmod +x ./prevent_commit_to_main.sh - uses: pre-commit/action@v3.0.0 with: extra_args: --all-files diff --git a/.gitignore b/.gitignore index 818e042..a25212e 100644 --- a/.gitignore +++ b/.gitignore @@ -24,6 +24,10 @@ venv/ *.egg-info/ .installed.cfg *.egg +bin/ +temp/ +tags/ +errors.err # PyInstaller # Usually these files are written by a python script from a template @@ -34,6 +38,7 @@ venv/ # Installer logs pip-log.txt pip-delete-this-directory.txt +MANIFEST # Unit test / coverage reports htmlcov/ @@ -50,6 +55,11 @@ coverage.xml *.mo *.pot +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + # Django stuff: *.log @@ -80,3 +90,10 @@ target/ # Ipython Notebook .ipynb_checkpoints + +# version information +setup.cfg +/src/diffpy/*/version.cfg + +# Rever +rever/ diff --git a/AUTHORS.rst b/AUTHORS.rst index a67fbda..726120f 100644 --- a/AUTHORS.rst +++ b/AUTHORS.rst @@ -1,13 +1,10 @@ +Authors ======= -Credits -======= - -Maintainer ----------- -* diffpy +Billinge Group and community contibutors. Contributors ------------ -None yet. Why not be the first? See: CONTRIBUTING.rst +For a list of contributors, visit +https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 0000000..686497f --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,7 @@ +============= +Release Notes +============= + +.. current developments + +Initial release of labPDFproc. Please see README and documentation for details diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 0000000..ff9c356 --- /dev/null +++ b/CODE_OF_CONDUCT.rst @@ -0,0 +1,133 @@ +===================================== + Contributor Covenant Code of Conduct +===================================== + +Our Pledge +---------- + +We as members, contributors, and leaders pledge to make participation in our +community a harassment-free experience for everyone, regardless of age, body +size, visible or invisible disability, ethnicity, sex characteristics, gender +identity and expression, level of experience, education, socio-economic status, +nationality, personal appearance, race, caste, color, religion, or sexual +identity and orientation. + +We pledge to act and interact in ways that contribute to an open, welcoming, +diverse, inclusive, and healthy community. + +Our Standards +------------- + +Examples of behavior that contributes to a positive environment for our +community include: + +* Demonstrating empathy and kindness toward other people +* Being respectful of differing opinions, viewpoints, and experiences +* Giving and gracefully accepting constructive feedback +* Accepting responsibility and apologizing to those affected by our mistakes, + and learning from the experience +* Focusing on what is best not just for us as individuals, but for the overall + community + +Examples of unacceptable behavior include: + +* The use of sexualized language or imagery, and sexual attention or advances of + any kind +* Trolling, insulting or derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or email address, + without their explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +Enforcement Responsibilities +---------------------------- + +Community leaders are responsible for clarifying and enforcing our standards of +acceptable behavior and will take appropriate and fair corrective action in +response to any behavior that they deem inappropriate, threatening, offensive, +or harmful. + +Community leaders have the right and responsibility to remove, edit, or reject +comments, commits, code, wiki edits, issues, and other contributions that are +not aligned to this Code of Conduct, and will communicate reasons for moderation +decisions when appropriate. + +Scope +----- + +This Code of Conduct applies within all community spaces, and also applies when +an individual is officially representing the community in public spaces. +Examples of representing our community include using an official email address, +posting via an official social media account, or acting as an appointed +representative at an online or offline event. + +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. + +All community leaders are obligated to respect the privacy and security of the +reporter of any incident. + +Enforcement Guidelines +---------------------- + +Community leaders will follow these Community Impact Guidelines in determining +the consequences for any action they deem in violation of this Code of Conduct: + +1. Correction +**************** + +**Community Impact**: Use of inappropriate language or other behavior deemed +unprofessional or unwelcome in the community. + +**Consequence**: A private, written warning from community leaders, providing +clarity around the nature of the violation and an explanation of why the +behavior was inappropriate. A public apology may be requested. + +2. Warning +************* + +**Community Impact**: A violation through a single incident or series of +actions. + +**Consequence**: A warning with consequences for continued behavior. No +interaction with the people involved, including unsolicited interaction with +those enforcing the Code of Conduct, for a specified period of time. This +includes avoiding interactions in community spaces as well as external channels +like social media. Violating these terms may lead to a temporary or permanent +ban. + +3. Temporary Ban +****************** + +**Community Impact**: A serious violation of community standards, including +sustained inappropriate behavior. + +**Consequence**: A temporary ban from any sort of interaction or public +communication with the community for a specified period of time. No public or +private interaction with the people involved, including unsolicited interaction +with those enforcing the Code of Conduct, is allowed during this period. +Violating these terms may lead to a permanent ban. + +4. Permanent Ban +****************** + +**Community Impact**: Demonstrating a pattern of violation of community +standards, including sustained inappropriate behavior, harassment of an +individual, or aggression toward or disparagement of classes of individuals. + +**Consequence**: A permanent ban from any sort of public interaction within the +community. + +Attribution +----------- + +This Code of Conduct is adapted from the `Contributor Covenant `_. + +Community Impact Guidelines were inspired by `Mozilla's code of conduct enforcement ladder `_. + +For answers to common questions about this code of conduct, see the `FAQ `_. `Translations are available `_ diff --git a/LICENSE.rst b/LICENSE.rst new file mode 100644 index 0000000..95a04ac --- /dev/null +++ b/LICENSE.rst @@ -0,0 +1,30 @@ +BSD 3-Clause License + +Copyright (c) 2024, The Trustees of Columbia University +in the City of New York. +All rights reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its contributors + may be used to endorse or promote products derived from this software + without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/MANIFEST.in b/MANIFEST.in index 09c54ff..a4ceb84 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,17 +1,16 @@ include AUTHORS.rst -include CONTRIBUTING.rst include LICENSE include README.rst include requirements.txt -include docs/examples/* +include doc/examples/* recursive-exclude * __pycache__ recursive-exclude * *.py[co] recursive-include docs *.rst conf.py Makefile make.bat -include versioneer.py -include labpdfproc/_version.py + +include diffpy.labpdfproc/version.py # If including data files in the package, add them like: # include path/to/data_file diff --git a/README.rst b/README.rst index cce4050..b0b8ab3 100644 --- a/README.rst +++ b/README.rst @@ -1,103 +1,118 @@ -================= -diffpy.labpdfproc -================= +|Icon| `diffpy.labpdfproc `_ +========================================================= -.. image:: https://github.com/diffpy/diffpy.labpdfproc/actions/workflows/testing.yml/badge.svg - :target: https://github.com/diffpy/diffpy.labpdfproc/actions/workflows/testing.yml +.. |Icon| image:: https://avatars.githubusercontent.com/diffpy + :target: https://diffpy.github.io/diffpy.labpdfproc + :height: 100px +|PyPi| |Forge| |PythonVersion| |PR| -.. image:: https://img.shields.io/pypi/v/diffpy.labpdfproc.svg - :target: https://pypi.python.org/pypi/diffpy.labpdfproc +|CI| |Codecov| |Black| |Tracking| +.. |Black| image:: https://img.shields.io/badge/code_style-black-black + :target: https://github.com/psf/black -An app for preprocessing data from laboratory x-ray diffractometers before using PDFgetX3 to obtain PDFs +.. |CI| image:: https://github.com/diffpy/diffpy.labpdfproc/actions/workflows/main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.labpdfproc/actions/workflows/main.yml -* Free software: 3-clause BSD license -* Documentation: (COMING SOON!) https://sbillinge.github.io/diffpy.labpdfproc. +.. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.labpdfproc/branch/main/graph/badge.svg + :target: https://codecov.io/gh/diffpy/diffpy.labpdfproc -Background ----------- +.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/diffpy.labpdfproc + :target: https://anaconda.org/conda-forge/diffpy.labpdfproc -PDFgetX3 has revolutionized how PDF methods can be applied to solve nanostructure problems. However, the program was designed for use with Rapid Acquisition PDF (RAPDF) data from synchrotron sources. A key approximation inherent in the use of PDFgetX3 for RAPDF data is that absorption effects are negligible. This is typically not the case for laboratory x-ray diffractometers, where absorption effects can be significant. +.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff -This app is designed to preprocess data from laboratory x-ray diffractometers before using PDFgetX3 to obtain PDFs. The app currently carries out an absorption correction assuming a parallel beam capillary geometry which is the most common geometry for lab PDF measurements. +.. |PyPi| image:: https://img.shields.io/pypi/v/diffpy.labpdfproc + :target: https://pypi.org/project/diffpy.labpdfproc/ -The theory is described in the following paper: +.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/diffpy.labpdfproc + :target: https://pypi.org/project/diffpy.labpdfproc/ -An ad hoc Absorption Correction for Reliable -Pair-Distribution Functions from Low Energy x-ray Sources -Yucong Chen, Till Schertenleib, Andrew Yang, Pascal Schouwink, -Wendy L. Queen and Simon J. L. Billinge, in preparation. +.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue + :target: https://github.com/diffpy/diffpy.labpdfproc/issues -The related experimental data acquisition protocols are described in the following paper: +Tools for processing x-ray powder diffraction data from laboratory sources -Protocols for Obtaining Reliable PDFs from Laboratory -x-ray Sources Using PDFgetX3, -Till Schertenleib, Daniel Schmuckler, Yucong Chen, Geng Bang Jin, -Wendy L. Queen and Simon J. L. Billinge, in preparation. +* LONGER DESCRIPTION HERE -Installation ------------- +For more information about the diffpy.labpdfproc library, please consult our `online documentation `_. + +Citation +-------- -The package is available on conda-forge and on pypi. Assuming you are using conda/mamba (we recommend using miniconda), create a virtual environment and install the package as follows: +If you use diffpy.labpdfproc in a scientific publication, we would like you to cite this package as -.. code-block:: python + diffpy.labpdfproc Package, https://github.com/diffpy/diffpy.labpdfproc - mamba create -n labpdfproc python=3.12 - mamba activate labpdfproc - cd path/to/diffpy.labpdfproc - mamba install -c conda-forge diffpy.labpdfproc +Installation +------------ -The code may also be installed from pipy using pip. This is not recommended as the package has not been tested on all platforms. +The preferred method is to use `Miniconda Python +`_ +and install from the "conda-forge" channel of Conda packages. -Usage ------ +To add "conda-forge" to the conda channels, run the following in a terminal. :: -Navigate to the directory that contains 1D diffraction patterns that you would like to process. Activate the conda environment (`conda activate labpdfproc`) that contains the package and run the following command: + conda config --add channels conda-forge -.. code-block:: python +We want to install our packages in a suitable conda environment. +The following creates and activates a new environment named ``diffpy.labpdfproc_env`` :: - labpdfproc -i --anode-type Mo + conda create -n diffpy.labpdfproc_env python=3 + conda activate diffpy.labpdfproc_env +Then, to fully install ``diffpy.labpdfproc`` in our active environment, run :: -Here replace with the value of muD for your sample and with the path and filename of your input file. For example, if the uncorrected data case isc alled zro2_mo.xy and is in the current directory and it has a muD of 2.5 then the commands would be + conda install diffpy.labpdfproc -.. code-block:: python +Another option is to use ``pip`` to download and install the latest release from +`Python Package Index `_. +To install using ``pip`` into your ``diffpy.labpdfproc_env`` environment, we will also have to install dependencies :: - labpdfproc 2.5 -i zro2_mo.xy --anode-type Mo + pip install -r https://raw.githubusercontent.com/diffpy/diffpy.labpdfproc/main/requirements/run.txt -Please type -.. code-block:: python +and then install the package :: - labpdfproc --help + pip install diffpy.labpdfproc -for more information on the available options. +If you prefer to install from sources, after installing the dependencies, obtain the source archive from +`GitHub `_. Once installed, ``cd`` into your ``diffpy.labpdfproc`` directory +and run the following :: + pip install . -Getting Started ---------------- +Support and Contribute +---------------------- -An example input file can be found in the docs/examples directory in the distribtuion (you should find it in your miniconda envs locateion). The file is called zro2_mo.xy. +`Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.labpdfproc. Please join the diffpy.labpdfproc users community by joining the Google group. The diffpy.labpdfproc project welcomes your expertise and enthusiasm! -1. Copy this file to a new scratch directory -2. Navigate to that directory in a terminal -3. Activate the conda environment that contains the package -4. Run the command (see above) +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 `_. -An example output is also present in the example data and you can compare your output to this file. The example was processed with a muD of 2.5, though for experimentation you can try processing data with different muD values. +Feel free to fork the project and contribute. To install diffpy.labpdfproc +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 :: -Contributing ------------- -We welcome contributors from the community. Please consider posting issues, and taking issues and posting PRs. + pip install -e . To ensure code quality and to prevent accidental commits into the default branch, please set up the use of our pre-commit hooks. -1. modify the permissions to executable on the bash script called `prevent_commit_to_main.sh` in this directory: `chmod +x prevent_commit_to_main.sh` -2. install pre-commit in your working environment `conda install pre-commit` -3. initialize pre-commit (one time only) `pre-commit install` +1. Install pre-commit in your working environment by running ``conda install pre-commit``. + +2. Initialize pre-commit (one time only) ``pre-commit install``. Thereafter your code will be linted by black and isort and checked against flake8 before you can commit. If it fails by black or isort, just rerun and it should pass (black and isort will modify the files so should -pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before -trying to commit again +pass after they are modified). If the flake8 test fails please see the error messages and fix them manually before +trying to commit again. + +Improvements and fixes are always appreciated. + +Before contribuing, please read our `Code of Conduct `_. + +Contact +------- + +For more information on diffpy.labpdfproc please visit the project `web-page `_ or email Prof. Simon Billinge at sb2896@columbia.edu. diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..a86d284 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,194 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +PAPER = +BUILDDIR = build +BASENAME = $(subst .,,$(subst $() $(),,diffpy.labpdfproc)) + +# User-friendly check for sphinx-build +ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) +$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) +endif + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source + +.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext + +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " dirhtml to make HTML files named index.html in directories" + @echo " singlehtml to make a single large HTML file" + @echo " pickle to make pickle files" + @echo " json to make JSON files" + @echo " htmlhelp to make HTML files and a HTML help project" + @echo " qthelp to make HTML files and a qthelp project" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" + @echo " latexpdf to make LaTeX files and run them through pdflatex" + @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" + @echo " text to make text files" + @echo " man to make manual pages" + @echo " texinfo to make Texinfo files" + @echo " info to make Texinfo files and run them through makeinfo" + @echo " gettext to make PO message catalogs" + @echo " changes to make an overview of all changed/added/deprecated items" + @echo " xml to make Docutils-native XML files" + @echo " pseudoxml to make pseudoxml-XML files for display purposes" + @echo " linkcheck to check all external links for integrity" + @echo " doctest to run all doctests embedded in the documentation (if enabled)" + +clean: + rm -rf $(BUILDDIR)/* + +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +htmlhelp: + $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp + @echo + @echo "Build finished; now you can run HTML Help Workshop with the" \ + ".hhp project file in $(BUILDDIR)/htmlhelp." + +qthelp: + $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp + @echo + @echo "Build finished; now you can run "qcollectiongenerator" with the" \ + ".qhcp project file in $(BUILDDIR)/qthelp, like this:" + @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/$(BASENAME).qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/$(BASENAME).qhc" + +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/$(BASENAME)" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/$(BASENAME)" + @echo "# devhelp" + +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +latex: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo + @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." + @echo "Run \`make' in that directory to run these through (pdf)latex" \ + "(use \`make latexpdf' here to do that automatically)." + +latexpdf: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through pdflatex..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +latexpdfja: + $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex + @echo "Running LaTeX files through platex and dvipdfmx..." + $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja + @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." + +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +texinfo: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo + @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." + @echo "Run \`make' in that directory to run these through makeinfo" \ + "(use \`make info' here to do that automatically)." + +info: + $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo + @echo "Running Texinfo files through makeinfo..." + make -C $(BUILDDIR)/texinfo info + @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." + +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +linkcheck: + $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck + @echo + @echo "Link check complete; look for any errors in the above output " \ + "or in $(BUILDDIR)/linkcheck/output.txt." + +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +# Manual publishing to the gh-pages branch + +GITREPOPATH = $(shell cd $(CURDIR) && git rev-parse --git-dir) +GITREMOTE = origin +GITREMOTEURL = $(shell git config --get remote.$(GITREMOTE).url) +GITLASTCOMMIT = $(shell git rev-parse --short HEAD) + +publish: + @test -d build/html || \ + ( echo >&2 "Run 'make html' first!"; false ) + git show-ref --verify --quiet refs/heads/gh-pages || \ + git branch --track gh-pages $(GITREMOTE)/gh-pages + test -d build/gh-pages || \ + git clone -s -b gh-pages $(GITREPOPATH) build/gh-pages + cd build/gh-pages && \ + git pull $(GITREMOTEURL) gh-pages + rsync -acv --delete --exclude=.git --exclude=.rsync-exclude \ + --exclude-from=build/gh-pages/.rsync-exclude \ + --link-dest=$(CURDIR)/build/html build/html/ build/gh-pages/ + cd build/gh-pages && \ + git add --all . && \ + git diff --cached --quiet || \ + git commit -m "Sync with the source at $(GITLASTCOMMIT)." + cd build/gh-pages && \ + git push origin gh-pages diff --git a/doc/manual/source/_static/.placeholder b/doc/_static/.placeholder similarity index 100% rename from doc/manual/source/_static/.placeholder rename to doc/_static/.placeholder diff --git a/doc/manual/examples/zro2_mo.xy b/doc/examples/zro2_mo.xy similarity index 100% rename from doc/manual/examples/zro2_mo.xy rename to doc/examples/zro2_mo.xy diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 0000000..2be8306 --- /dev/null +++ b/doc/make.bat @@ -0,0 +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 diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py deleted file mode 100644 index 2d8622c..0000000 --- a/doc/manual/source/conf.py +++ /dev/null @@ -1,214 +0,0 @@ -#!/usr/bin/env python3 -# -*- coding: utf-8 -*- -# -# diffpy.labpdfproc documentation build configuration file, created by -# sphinx-quickstart on Thu Jun 28 12:35:56 2018. -# -# This file is execfile()d with the current directory set to its -# containing dir. -# -# Note that not all possible configuration values are present in this -# autogenerated file. -# -# All configuration values have a default; values that are commented out -# serve to show the default. - -# 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 os.path.abspath to make it absolute, like shown here. -# -# import os -# import sys -# sys.path.insert(0, os.path.abspath('.')) - - -# -- General configuration ------------------------------------------------ - -# If your documentation needs a minimal Sphinx version, state it here. -# -# needs_sphinx = '1.0' - -# Add any Sphinx extension module names here, as strings. They can be -# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom -# ones. -extensions = [ - "sphinx.ext.autodoc", - "sphinx.ext.autosummary", - "sphinx.ext.githubpages", - "sphinx.ext.intersphinx", - "sphinx.ext.mathjax", - "sphinx.ext.viewcode", - "IPython.sphinxext.ipython_directive", - "IPython.sphinxext.ipython_console_highlighting", - "matplotlib.sphinxext.plot_directive", - "numpydoc", - "sphinx_copybutton", -] - -# Configuration options for plot_directive. See: -# https://github.com/matplotlib/matplotlib/blob/f3ed922d935751e08494e5fb5311d3050a3b637b/lib/matplotlib/sphinxext/plot_directive.py#L81 -plot_html_show_source_link = False -plot_html_show_formats = False - -# Generate the API documentation when building -autosummary_generate = True -numpydoc_show_class_members = False - -# Add any paths that contain templates here, relative to this directory. -templates_path = ["_templates"] - -# The suffix(es) of source filenames. -# You can specify multiple suffix as a list of string: -# -# source_suffix = ['.rst', '.md'] -source_suffix = ".rst" - -# The master toctree document. -master_doc = "index" - -# General information about the project. -project = "diffpy.labpdfproc" -copyright = "2024, diffpy" -author = "diffpy" - -# The version info for the project you're documenting, acts as replacement for -# |version| and |release|, also used in various other places throughout the -# built documents. -# -import diffpy.labpdfproc - -# The short X.Y version. -version = diffpy.labpdfproc.__version__ -# The full version, including alpha/beta/rc tags. -release = diffpy.labpdfproc.__version__ - -# The language for content autogenerated by Sphinx. Refer to documentation -# for a list of supported languages. -# -# This is also used if you do content translation via gettext catalogs. -# Usually you set "language" from the command line for these cases. -language = "en" - -# List of patterns, relative to source directory, that match files and -# directories to ignore when looking for source files. -# This patterns also effect to html_static_path and html_extra_path -exclude_patterns = [] - -# The name of the Pygments (syntax highlighting) style to use. -pygments_style = "sphinx" - -# If true, `todo` and `todoList` produce output, else they produce nothing. -todo_include_todos = False - - -# -- Options for HTML output ---------------------------------------------- - -# The theme to use for HTML and HTML Help pages. See the documentation for -# a list of builtin themes. -# -html_theme = "sphinx_rtd_theme" -import sphinx_rtd_theme - -html_theme_path = [sphinx_rtd_theme.get_html_theme_path()] - -# Theme options are theme-specific and customize the look and feel of a theme -# further. For a list of options available for each theme, see the -# documentation. -# -# html_theme_options = {} - -# Add any paths that contain custom static files (such as style sheets) here, -# relative to this directory. They are copied after the builtin static files, -# so a file named "default.css" will overwrite the builtin "default.css". -html_static_path = ["_static"] - -# Custom sidebar templates, must be a dictionary that maps document names -# to template names. -# -# This is required for the alabaster theme -# refs: http://alabaster.readthedocs.io/en/latest/installation.html#sidebars -html_sidebars = { - "**": [ - "relations.html", # needs 'show_related': True theme option to display - "searchbox.html", - ] -} - - -# -- Options for HTMLHelp output ------------------------------------------ - -# Output file base name for HTML help builder. -htmlhelp_basename = "diffpy.labpdfproc" - - -# -- Options for LaTeX output --------------------------------------------- - -latex_elements = { - # The paper size ('letterpaper' or 'a4paper'). - # 'papersize': 'letterpaper', - # - # The font size ('10pt', '11pt' or '12pt'). - # 'pointsize': '10pt', - # - # Additional stuff for the LaTeX preamble. - # 'preamble': '', - # - # Latex figure (float) alignment - # 'figure_align': 'htbp', -} - -# Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, -# author, documentclass [howto, manual, or own class]). -latex_documents = [ - ( - master_doc, - "diffpy.labpdfproc.tex", - "diffpy.labpdfproc Documentation", - "Contributors", - "manual", - ), -] - - -# -- Options for manual page output --------------------------------------- - -# One entry per manual page. List of tuples -# (source start file, name, description, authors, manual section). -man_pages = [ - ( - master_doc, - "diffpy.labpdfproc", - "diffpy.labpdfproc Documentation", - [author], - 1, - ) -] - - -# -- Options for Texinfo output ------------------------------------------- - -# Grouping the document tree into Texinfo files. List of tuples -# (source start file, target name, title, author, -# dir menu entry, description, category) -texinfo_documents = [ - ( - master_doc, - "diffpy.labpdfproc", - "diffpy.labpdfproc Documentation", - author, - "diffpy.labpdfproc", - "An app for preprocessing data from laboratory x-ray diffractometers before using PDFgetX3 to obtain PDFs", - "Miscellaneous", - ), -] - - -# Example configuration for intersphinx: refer to the Python standard library. -intersphinx_mapping = { - "python": ("https://docs.python.org/3/", None), - "numpy": ("https://numpy.org/doc/stable/", None), - "scipy": ("https://docs.scipy.org/doc/scipy/reference/", None), - "pandas": ("https://pandas.pydata.org/pandas-docs/stable", None), - "matplotlib": ("https://matplotlib.org/stable", None), -} diff --git a/doc/manual/source/index.rst b/doc/manual/source/index.rst deleted file mode 100644 index 08f43fc..0000000 --- a/doc/manual/source/index.rst +++ /dev/null @@ -1,15 +0,0 @@ -.. Packaging Scientific Python documentation master file, created by - sphinx-quickstart on Thu Jun 28 12:35:56 2018. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - -diffpy.labpdfproc Documentation -=============================== - -.. toctree:: - :maxdepth: 2 - - installation - usage - release-history - min_versions diff --git a/doc/source/_static/.placeholder b/doc/source/_static/.placeholder new file mode 100644 index 0000000..e69de29 diff --git a/doc/source/api/diffpy.labpdfproc.rst b/doc/source/api/diffpy.labpdfproc.rst new file mode 100644 index 0000000..4f0a72d --- /dev/null +++ b/doc/source/api/diffpy.labpdfproc.rst @@ -0,0 +1,36 @@ +:tocdepth: -1 + +diffpy.labpdfproc package +========================= + +.. automodule:: diffpy.labpdfproc + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.labpdfproc.functions module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.labpdfproc.functions + :members: + :undoc-members: + :show-inheritance: + +diffpy.labpdfproc.tools module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.labpdfproc.tools + :members: + :undoc-members: + :show-inheritance: + +diffpy.labpdfproc.labpdfprocapp module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.labpdfproc.labpdfprocapp + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 0000000..688e25c --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,291 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# diffpy.labpdfproc documentation build configuration file, created by +# sphinx-quickstart on Thu Jan 30 15:49:41 2014. +# +# This file is execfile()d with the current directory set to its +# containing dir. +# +# Note that not all possible configuration values are present in this +# autogenerated file. +# +# All configuration values have a default; values that are commented out +# serve to show the default. + +import sys +import time +from importlib.metadata import version +from pathlib import Path + +autodoc_mock_imports = ["diffpy.utils", "numpy"] + +# 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. +# 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 = "Billinge Group members and community contributors" + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +# needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + "sphinx.ext.autodoc", + "sphinx.ext.napoleon", + "sphinx.ext.todo", + "sphinx.ext.viewcode", + "sphinx.ext.intersphinx", + "sphinx_rtd_theme", + "m2r", +] + +# Add any paths that contain templates here, relative to this directory. +templates_path = ["_templates"] + +# The suffix(es) of source filenames. +# You can specify multiple suffix as a list of string: +# +source_suffix = [".rst", ".md"] + +# The encoding of source files. +# source_encoding = 'utf-8-sig' + +# The master toctree document. +master_doc = "index" + +# General information about the project. +project = "diffpy.labpdfproc" +copyright = "%Y, The Trustees of Columbia University in the City of New York" + +# The version info for the project you're documenting, acts as replacement for +# |version| and |release|, also used in various other places throughout the +# built documents. + +fullversion = version(project) +# The short X.Y version. +version = "".join(fullversion.split(".post")[:1]) +# The full version, including alpha/beta/rc tags. +release = fullversion + +# The language for content autogenerated by Sphinx. Refer to documentation +# for a list of supported languages. +# language = None + +# There are two options for replacing |today|: either, you set today to some +# non-false value, then it is used: +# today = '' +today = time.strftime("%B %d, %Y", time.localtime()) +year = today.split()[-1] +# Else, today_fmt is used as the format for a strftime call. +# today_fmt = '%B %d, %Y' +# substitute YEAR in the copyright string +copyright = copyright.replace("%Y", year) + +# List of patterns, relative to source directory, that match files and +# directories to ignore when looking for source files. +exclude_patterns = ["build"] + +# The reST default role (used for this markup: `text`) to use for all +# documents. +# default_role = None + +# If true, '()' will be appended to :func: etc. cross-reference text. +# add_function_parentheses = True + +# If true, the current module name will be prepended to all description +# unit titles (such as .. function::). +# add_module_names = True + +# If true, sectionauthor and moduleauthor directives will be shown in the +# output. They are ignored by default. +# show_authors = False + +# The name of the Pygments (syntax highlighting) style to use. +pygments_style = "sphinx" + +# A list of ignored prefixes for module index sorting. +modindex_common_prefix = ["diffpy.labpdfproc"] + +# Display all warnings for missing links. +nitpicky = True + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +# +html_theme = "sphinx_rtd_theme" + +# Theme options are theme-specific and customize the look and feel of a theme +# further. For a list of options available for each theme, see the +# documentation. +# +html_theme_options = { + "navigation_with_keys": "true", +} + +# Add any paths that contain custom themes here, relative to this directory. +# html_theme_path = [] + +# The name for this set of Sphinx documents. If None, it defaults to +# " v documentation". +# html_title = None + +# A shorter title for the navigation bar. Default is the same as html_title. +# html_short_title = None + +# The name of an image file (relative to this directory) to place at the top +# of the sidebar. +# html_logo = None + +# The name of an image file (within the static path) to use as favicon of the +# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32 +# pixels large. +# html_favicon = None + +# Add any paths that contain custom static files (such as style sheets) here, +# relative to this directory. They are copied after the builtin static files, +# so a file named "default.css" will overwrite the builtin "default.css". +# html_static_path = ['_static'] + +# Add any extra paths that contain custom files (such as robots.txt or +# .htaccess) here, relative to this directory. These files are copied +# directly to the root of the documentation. +# html_extra_path = [] + +# If not '', a 'Last updated on:' timestamp is inserted at every page bottom, +# using the given strftime format. +# html_last_updated_fmt = '%b %d, %Y' + +# If true, SmartyPants will be used to convert quotes and dashes to +# typographically correct entities. +# html_use_smartypants = True + +# Custom sidebar templates, maps document names to template names. +# html_sidebars = {} + +# Additional templates that should be rendered to pages, maps page names to +# template names. +# html_additional_pages = {} + +# If false, no module index is generated. +# html_domain_indices = True + +# If false, no index is generated. +# html_use_index = True + +# If true, the index is split into individual pages for each letter. +# html_split_index = False + +# If true, links to the reST sources are added to the pages. +# html_show_sourcelink = True + +# If true, "Created using Sphinx" is shown in the HTML footer. Default is True. +# html_show_sphinx = True + +# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True. +# html_show_copyright = True + +# If true, an OpenSearch description file will be output, and all pages will +# contain a tag referring to it. The value of this option must be the +# base URL from which the finished HTML is served. +# html_use_opensearch = '' + +# This is the file name suffix for HTML files (e.g. ".xhtml"). +# html_file_suffix = None + +# Output file base name for HTML help builder. +basename = "diffpy.labpdfproc".replace(" ", "").replace(".", "") +htmlhelp_basename = basename + "doc" + + +# -- Options for LaTeX output --------------------------------------------- + +latex_elements = { + # The paper size ('letterpaper' or 'a4paper'). + # 'papersize': 'letterpaper', + # The font size ('10pt', '11pt' or '12pt'). + # 'pointsize': '10pt', + # Additional stuff for the LaTeX preamble. + # 'preamble': '', +} + +# Grouping the document tree into LaTeX files. List of tuples +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). +latex_documents = [ + ("index", "diffpy.labpdfproc.tex", "diffpy.labpdfproc Documentation", ab_authors, "manual"), +] + +# The name of an image file (relative to this directory) to place at the top of +# the title page. +# latex_logo = None + +# For "manual" documents, if this is true, then toplevel headings are parts, +# not chapters. +# latex_use_parts = False + +# If true, show page references after internal links. +# latex_show_pagerefs = False + +# If true, show URL addresses after external links. +# latex_show_urls = False + +# Documents to append as an appendix to all manuals. +# latex_appendices = [] + +# If false, no module index is generated. +# latex_domain_indices = True + + +# -- Options for manual page output --------------------------------------- + +# One entry per manual page. List of tuples +# (source start file, name, description, authors, manual section). +man_pages = [("index", "diffpy.labpdfproc", "diffpy.labpdfproc Documentation", ab_authors, 1)] + +# If true, show URL addresses after external links. +# man_show_urls = False + + +# -- Options for Texinfo output ------------------------------------------- + +# Grouping the document tree into Texinfo files. List of tuples +# (source start file, target name, title, author, +# dir menu entry, description, category) +texinfo_documents = [ + ( + "index", + "diffpy.labpdfproc", + "diffpy.labpdfproc Documentation", + ab_authors, + "diffpy.labpdfproc", + "One line description of project.", + "Miscellaneous", + ), +] + +# Documents to append as an appendix to all manuals. +# texinfo_appendices = [] + +# If false, no module index is generated. +# texinfo_domain_indices = True + +# How to display URL addresses: 'footnote', 'no', or 'inline'. +# texinfo_show_urls = 'footnote' + +# If true, do not generate a @detailmenu in the "Top" node's menu. +# texinfo_no_detailmenu = False + + +# Example configuration for intersphinx: refer to the Python standard library. +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 0000000..7fc14b4 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,44 @@ +####### +|title| +####### + +.. |title| replace:: diffpy.labpdfproc documentation + +diffpy.labpdfproc - Tools for processing x-ray powder diffraction data from laboratory sources. + +| Software version |release|. +| Last updated |today|. + +======= +Authors +======= + +diffpy.labpdfproc is developed by Billinge Group +and its community contributors. + +For a detailed list of contributors see +https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors. + +============ +Installation +============ + +See the `README `_ +file included with the distribution. + +================= +Table of contents +================= +.. toctree:: + :titlesonly: + + license + release + Package API + +======= +Indices +======= + +* :ref:`genindex` +* :ref:`search` diff --git a/doc/manual/source/installation.rst b/doc/source/installation.rst similarity index 100% rename from doc/manual/source/installation.rst rename to doc/source/installation.rst diff --git a/doc/source/license.rst b/doc/source/license.rst new file mode 100644 index 0000000..cfab61c --- /dev/null +++ b/doc/source/license.rst @@ -0,0 +1,39 @@ +:tocdepth: -1 + +.. index:: license + +License +####### + +OPEN SOURCE LICENSE AGREEMENT +============================= +BSD 3-Clause License + +Copyright (c) 2024, The Trustees of Columbia University in +the City of New York. +All Rights Reserved. + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions are met: + +1. Redistributions of source code must retain the above copyright notice, this + list of conditions and the following disclaimer. + +2. Redistributions in binary form must reproduce the above copyright notice, + this list of conditions and the following disclaimer in the documentation + and/or other materials provided with the distribution. + +3. Neither the name of the copyright holder nor the names of its + contributors may be used to endorse or promote products derived from + this software without specific prior written permission. + +THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" +AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE +IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE +DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE +FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL +DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR +SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER +CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, +OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE +OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. diff --git a/doc/manual/source/min_versions.rst b/doc/source/min_versions.rst similarity index 100% rename from doc/manual/source/min_versions.rst rename to doc/source/min_versions.rst diff --git a/doc/manual/source/release-history.rst b/doc/source/release-history.rst similarity index 100% rename from doc/manual/source/release-history.rst rename to doc/source/release-history.rst diff --git a/doc/source/release.rst b/doc/source/release.rst new file mode 100644 index 0000000..27cd0cc --- /dev/null +++ b/doc/source/release.rst @@ -0,0 +1,5 @@ +:tocdepth: -1 + +.. index:: release notes + +.. include:: ../../CHANGELOG.rst diff --git a/doc/manual/source/usage.rst b/doc/source/usage.rst similarity index 100% rename from doc/manual/source/usage.rst rename to doc/source/usage.rst diff --git a/news/TEMPLATE.rst b/news/TEMPLATE.rst new file mode 100644 index 0000000..790d30b --- /dev/null +++ b/news/TEMPLATE.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/pyproject.toml b/pyproject.toml index 4f11ecf..90c9dca 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -12,11 +12,11 @@ maintainers = [ { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, ] description = "Tools for processing x-ray powder diffraction data from laboratory sources" -keywords = ["powder xrd", "absorption correction"] +keywords = ['powder xrd', 'absorption correction', 'pdf', 'diffpy'] readme = "README.rst" requires-python = ">=3.10" classifiers = [ - 'Development Status :: 4 - Beta', + 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', @@ -29,11 +29,12 @@ classifiers = [ 'Programming Language :: Python :: 3.11', 'Programming Language :: Python :: 3.12', 'Topic :: Scientific/Engineering :: Physics', + 'Topic :: Scientific/Engineering :: Chemistry', ] [project.urls] Homepage = "https://github.com/diffpy/diffpy.labpdfproc/" -Issues = "https://github.com/diffpy/diffpy.labpdfproc/issues" +Issues = "https://github.com/diffpy/diffpy.labpdfproc/issues/" [tool.setuptools-git-versioning] enabled = true @@ -41,12 +42,9 @@ template = "{tag}" dev_template = "{tag}" dirty_template = "{tag}" -[project.scripts] -labpdfproc = "diffpy.labpdfproc.labpdfprocapp:main" - [tool.setuptools.packages.find] where = ["src"] # list of folders that contain the packages (["."] by default) -include = ["diffpy*"] # package names should match these glob patterns (["*"] by default) +include = ["*"] # package names should match these glob patterns (["*"] by default) exclude = ["diffpy.labpdfproc.tests*"] # exclude packages matching these glob patterns (empty by default) namespaces = false # to disable scanning PEP 420 namespaces (true by default) @@ -60,6 +58,8 @@ exclude = ''' | \.mypy_cache | \.tox | \.venv + | \.rst + | \.txt | _build | buck-out | build diff --git a/requirements/README.txt b/requirements/README.txt new file mode 100644 index 0000000..dc34909 --- /dev/null +++ b/requirements/README.txt @@ -0,0 +1,11 @@ +# YOU MAY DELETE THIS FILE AFTER SETTING UP DEPENDENCIES! +# +# This directory is where you should place your project dependencies. +# "pip.txt" should contain all required packages not available on conda. +# All other files should contain only packages available to download from conda. +# build.txt should contain all packages required to build (not run) the project. +# run.txt should contain all packages (including optional packages) required for a user to run the program. +# test.txt should contain all packages required for the testing suite and to ensure all tests pass. +# docs.txt should contain all packages required for building the package documentation page. +# +# YOU MAY DELETE THIS FILE AFTER SETTING UP DEPENDENCIES! diff --git a/requirements/build.txt b/requirements/build.txt new file mode 100644 index 0000000..f72d870 --- /dev/null +++ b/requirements/build.txt @@ -0,0 +1,2 @@ +python +setuptools diff --git a/requirements/pip.txt b/requirements/pip.txt new file mode 100644 index 0000000..e69de29 diff --git a/requirements/requirements.txt b/requirements/run.txt similarity index 90% rename from requirements/requirements.txt rename to requirements/run.txt index 22de6f3..33f7d26 100644 --- a/requirements/requirements.txt +++ b/requirements/run.txt @@ -1,4 +1,3 @@ # List required packages in this file, one per line. numpy -pathlib diffpy.utils diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 0000000..52184e7 --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,6 @@ +flake8 +pytest +codecov +coverage +pytest-env +pytest-mock diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index 3a0a226..751b01c 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -1,22 +1,19 @@ #!/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. +# 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_DANSE.txt for license information. +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## -"""diffpy - tools for structure analysis by diffraction. - -Blank namespace package. -""" +"""Blank namespace package for module diffpy.""" from pkgutil import extend_path diff --git a/src/diffpy/labpdfproc/__init__.py b/src/diffpy/labpdfproc/__init__.py index f37a775..dc5b3c6 100644 --- a/src/diffpy/labpdfproc/__init__.py +++ b/src/diffpy/labpdfproc/__init__.py @@ -1,27 +1,24 @@ #!/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. +# 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_DANSE.txt for license information. +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## -"""diffpy - tools for structure analysis by diffraction. - -Blank namespace package. -""" - - -from pkgutil import extend_path +"""Tools for processing x-ray powder diffraction data from laboratory sources""" -__path__ = extend_path(__path__, __name__) +# package version +from diffpy.labpdfproc.version import __version__ +# silence the pyflakes syntax checker +assert __version__ or True # End of file diff --git a/src/diffpy/labpdfproc/tests/debug.py b/src/diffpy/labpdfproc/tests/debug.py new file mode 100644 index 0000000..51881b9 --- /dev/null +++ b/src/diffpy/labpdfproc/tests/debug.py @@ -0,0 +1,35 @@ +#!/usr/bin/env python +############################################################################## +# +# (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.labpdfproc/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## + +""" +Convenience module for debugging the unit tests using + +python -m diffpy.labpdfproc.tests.debug + +Exceptions raised by failed tests or other errors are not caught. +""" + + +if __name__ == "__main__": + import sys + + from diffpy.labpdfproc.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/labpdfproc/tests/run.py b/src/diffpy/labpdfproc/tests/run.py new file mode 100644 index 0000000..d11095f --- /dev/null +++ b/src/diffpy/labpdfproc/tests/run.py @@ -0,0 +1,34 @@ +#!/usr/bin/env python +############################################################################## +# +# (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.labpdfproc/graphs/contributors +# +# See LICENSE.rst for license information. +# +############################################################################## +"""Convenience module for executing all unit tests with +python -m diffpy.labpdfproc.tests.run +""" + +import sys + +import pytest + +if __name__ == "__main__": + # show output results from every test function + args = ["-v"] + # show the message output for skipped and expected failure tests + if len(sys.argv) > 1: + args.extend(sys.argv[1:]) + print("pytest arguments: {}".format(args)) + # call pytest and exit with the return code from pytest + exit_res = pytest.main(args) + sys.exit(exit_res) + +# End of file diff --git a/src/diffpy/labpdfproc/version.py b/src/diffpy/labpdfproc/version.py index 7e9d113..9eec494 100644 --- a/src/diffpy/labpdfproc/version.py +++ b/src/diffpy/labpdfproc/version.py @@ -1,58 +1,26 @@ #!/usr/bin/env python ############################################################################## # -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2011 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. +# 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_DANSE.txt for license information. +# See GitHub contributions for a more detailed list of contributors. +# https://github.com/diffpy/diffpy.labpdfproc/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## -""" -Definition of __version__, __date__, __timestamp__, __git_commit__. - -Notes ------ -Variable `__gitsha__` is deprecated as of version 3.0. -Use `__git_commit__` instead. -""" - -__all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] - -import os.path -from importlib.resources import as_file, files - -# obtain version information from the version.cfg file -cp = dict(version="", date="", commit="", timestamp="0") -if __package__ is not None: - ref = files(__package__) / "version.cfg" - with as_file(ref) as fcfg: - if not os.path.isfile(fcfg): # pragma: no cover - from warnings import warn - - warn("Package metadata not found.") - fcfg = os.devnull - with open(fcfg) as fp: - kwords = [ - [w.strip() for w in line.split(" = ", 1)] for line in fp if line[:1].isalpha() and " = " in line - ] - assert all(w[0] in cp for w in kwords), "received unrecognized keyword" - cp.update(kwords) - del kwords +"""Definition of __version__.""" -__version__ = cp["version"] -__date__ = cp["date"] -__git_commit__ = cp["commit"] -__timestamp__ = int(cp["timestamp"]) +# We do not use the other three variables, but can be added back if needed. +# __all__ = ["__date__", "__git_commit__", "__timestamp__", "__version__"] -# TODO remove deprecated __gitsha__ in version 3.1. -__gitsha__ = __git_commit__ +# obtain version information +from importlib.metadata import version -del cp +__version__ = version("diffpy.labpdfproc") # End of file