diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 00000000..e5679fe5 --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,32 @@ +name: Check News Item + +on: + pull_request_target: + branches: + - main + +permissions: + pull-requests: write + contents: read + +jobs: + build: + runs-on: ubuntu-latest + name: Check News item + steps: + + # note: the checkout will pull code from the base branch. This step should not pull code from the merge commit + - uses: actions/checkout@v4 + + - name: Setup Python + uses: actions/setup-python@v5 + with: + python-version: '3.12' + cache: 'pip' + cache-dependency-path: 'pyproject.toml' + - run: pip install PyGithub + - run: python .github/workflows/check-news.py + env: + PR_NUMBER: "${{ github.event.number }}" + GITHUB_TOKEN: "${{ secrets.GITHUB_TOKEN }}" + GITHUB_REPOSITORY: "${{ env.GITHUB_REPOSITORY }}" diff --git a/.github/workflows/check-news.py b/.github/workflows/check-news.py new file mode 100644 index 00000000..2bf255df --- /dev/null +++ b/.github/workflows/check-news.py @@ -0,0 +1,62 @@ +"""Check if the PR has a news item. + +Put a warning comment if it doesn't. +""" + +import os +from fnmatch import fnmatch + +from github import Github, PullRequest + + +def get_added_files(pr: PullRequest.PullRequest): + print(pr, pr.number) + for file in pr.get_files(): + if file.status == "added": + yield file.filename + + +def check_news_file(pr): + return any(map(lambda file_name: fnmatch(file_name, "news/*.rst"), get_added_files(pr))) + + +def get_pr_number(): + number = os.environ["PR_NUMBER"] + if not number: + raise Exception(f"Pull request number is not found `PR_NUMBER={number}") + return int(number) + + +def get_old_comment(pr: PullRequest.PullRequest): + for comment in pr.get_issue_comments(): + if ("github-actions" in comment.user.login) and ("No news item is found" in comment.body): + return comment + + +def main(): + # using an access token + gh = Github(os.environ["GITHUB_TOKEN"]) + repo = gh.get_repo(os.environ["GITHUB_REPOSITORY"]) + pr = repo.get_pull(get_pr_number()) + has_news_added = check_news_file(pr) + old_comment = get_old_comment(pr) + + if old_comment: + print("Found an existing comment from bot") + if has_news_added: + print("Delete warning from bot, since news items is added.") + old_comment.delete() + elif not has_news_added: + print("No news item found") + + pr.create_issue_comment( + """\ +**Warning!** No news item is found for this PR. If this is an user facing change/feature/fix, + please add a news item by copying the format from `news/TEMPLATE.rst`. +""" + ) + assert False + + +if __name__ == "__main__": + main() diff --git a/.github/workflows/codecov.yml b/.github/workflows/codecov.yml new file mode 100644 index 00000000..29f65335 --- /dev/null +++ b/.github/workflows/codecov.yml @@ -0,0 +1,54 @@ +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 PROJECT_NAME + 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 PROJECT_NAME and requirements + run: | + conda install --file requirements/build.txt + 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: Validate PROJECT_NAME + run: | + 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 new file mode 100644 index 00000000..b71567ab --- /dev/null +++ b/.github/workflows/docs.yml @@ -0,0 +1,48 @@ +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 PROJECT_NAME + 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 PROJECT_NAME 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 new file mode 100644 index 00000000..e021b161 --- /dev/null +++ b/.github/workflows/main.yml @@ -0,0 +1,43 @@ +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.srfit + 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.srfit and requirements + run: | + conda install --file requirements/run.txt + conda install --file requirements/build.txt + conda install --file requirements/test.txt + python -m pip install -r requirements/pip.txt + python -m pip install . --no-deps + + - name: Validate diffpy.srfit + run: python -m pytest diff --git a/.isort.cfg b/.isort.cfg new file mode 100644 index 00000000..e0926f42 --- /dev/null +++ b/.isort.cfg @@ -0,0 +1,4 @@ +[settings] +line_length = 115 +multi_line_output = 3 +include_trailing_comma = True diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 00000000..9f3f16dc --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,10 @@ +Authors +======= + +Billinge Group and community contibutors. + +Contributors +------------ + +For a list of contributors, visit +https://github.com/diffpy/diffpy.srfit/graphs/contributors diff --git a/CHANGELOG.rst b/CHANGELOG.rst new file mode 100644 index 00000000..26694512 --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,5 @@ +============= +Release Notes +============= + +.. current developments diff --git a/CODE_OF_CONDUCT.rst b/CODE_OF_CONDUCT.rst new file mode 100644 index 00000000..ff9c3561 --- /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 00000000..95a04ac9 --- /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/doc/Makefile b/doc/Makefile index a265fe5d..3720ec8e 100644 --- a/doc/Makefile +++ b/doc/Makefile @@ -1,33 +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.srfit)) + +# 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)" -all: doc examples upload - -RELEASE = alpha9 -TARGET = farrowch@login.cacr.caltech.edu -DOCROOT = ~/docroot/diffraction/ -PKGROOT = ~/dev_danse_us/ - -.PHONY : doc -doc: - epydoc diffpy.srfit --html -vvv -o diffpy.srfitapi -n diffpy.srfit \ ---include-log --exclude diffpy.srfit.structure.cctbxstructure $@ - $(MAKE) -C devmanual $@ - -.PHONY : upload -upload: - rsync -ruvz --delete diffpy.srfitapi $(TARGET):$(DOCROOT) - ssh $(TARGET) "rm -rf $(DOCROOT)/diffpy.srfitapi-$(RELEASE)" - ssh $(TARGET) "cp -r $(DOCROOT)/diffpy.srfitapi $(DOCROOT)/diffpy.srfitapi-$(RELEASE)" - rsync -ruv srfit_examples.zip $(TARGET):$(PKGROOT) - ssh $(TARGET) "rm -rf $(PKGROOT)/srfit_examples-$(RELEASE).zip" - ssh $(TARGET) "cp -r $(PKGROOT)/srfit_examples.zip $(PKGROOT)/srfit_examples-$(RELEASE).zip" - $(MAKE) -C devmanual $@ - -.PHONY : examples -examples: - zip -r srfit_examples.zip ./examples/*.py ./examples/data -x \*svn\* -x \*threedoublepeaks\* -x \*temp\* -x \*test\* - -.PHONY : clean clean: - rm -rf diffpy.srfitapi - rm -f srfit_examples.zip - $(MAKE) -C devmanual $@ + 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/examples/npintensity.py b/doc/examples/npintensity.py index 3f3023cf..41a41d08 100644 --- a/doc/examples/npintensity.py +++ b/doc/examples/npintensity.py @@ -47,13 +47,7 @@ import numpy from gaussianrecipe import scipyOptimize -from diffpy.srfit.fitbase import ( - FitContribution, - FitRecipe, - FitResults, - Profile, - ProfileGenerator, -) +from diffpy.srfit.fitbase import FitContribution, FitRecipe, FitResults, Profile, ProfileGenerator from diffpy.srfit.structure.diffpyparset import DiffpyStructureParSet # Example Code diff --git a/doc/make.bat b/doc/make.bat new file mode 100644 index 00000000..ac53d5bd --- /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/Makefile b/doc/manual/Makefile deleted file mode 100644 index beb126b4..00000000 --- a/doc/manual/Makefile +++ /dev/null @@ -1,179 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# 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 publish - -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 " 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 " 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/SrFit.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/SrFit.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/SrFit" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/SrFit" - @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." - -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/api/diffpy.srfit.rst b/doc/manual/source/api/diffpy.srfit.rst deleted file mode 100644 index bbe6224d..00000000 --- a/doc/manual/source/api/diffpy.srfit.rst +++ /dev/null @@ -1,38 +0,0 @@ -:tocdepth: 2 - -diffpy.srfit package -==================== - -Subpackages ------------ - -.. toctree:: - :maxdepth: 2 - - diffpy.srfit.equation - diffpy.srfit.fitbase - diffpy.srfit.interface - diffpy.srfit.pdf - diffpy.srfit.sas - diffpy.srfit.structure - diffpy.srfit.util - -Submodules ----------- - -diffpy.srfit.version module ---------------------------- - -.. automodule:: diffpy.srfit.version - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: diffpy.srfit - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/manual/source/index.rst b/doc/manual/source/index.rst deleted file mode 100644 index ea21479d..00000000 --- a/doc/manual/source/index.rst +++ /dev/null @@ -1,84 +0,0 @@ -.. _developers-guide-index: - -#################################################### -diffpy.srfit documentation -#################################################### - -diffpy.srfit - configurable code for solving atomic structures. - -| Software version |release|. -| Last updated |today|. - -The diffpy.srfit package provides the framework for building a global optimizer -on the fly from components such as function calculators (that calculate -different data spectra), regression algorithms and structure models. The -software is capable of co-refinement using multiple information sources or -models. It provides a uniform interface for various regression algorithms. The -target function being optimized can be specified by the user according to the -data available. - -Within the diffpy.srfit framework, any parameter used in describing the -structure of a material can be passed as a refinable variable to the global -optimizer. Once parameters are declared as variables they can easily be turned -"on" or "off", i.e. fixed or allowed to vary. Additionally, variables may be -constrained to obey mathematical relationships with other parameters or -variables used in the structural model. Restraints can be applied to -variables, which adds a penalty to the refinement process commensurate with the -deviation from the known value or range. The cost function can also be -customized by the user. If the refinement contains multiple models, each model -can have its own cost function which will be properly weighted and combined to -obtain the total cost function. Additionally, diffpy.srfit is designed to be -extensible, allowing the user to integrate external calculators to perform -co-refinements with other techniques. - -======================================== -Authors -======================================== - -diffpy.srfit is developed by members of the Billinge Group at -Columbia University and at Brookhaven National Laboratory including -Christopher L. Farrow, Pavol Juhás, Simon J.L. Billinge. - -The source code in *observable.py* was derived from the 1.0 version -of the Caltech "Pyre" project. - -For a detailed list of contributors see -https://github.com/diffpy/diffpy.srfit/graphs/contributors. - -====================================== -Installation -====================================== - -See the `README `_ -file included with the distribution. - -====================================== -Where next? -====================================== - -.. toctree:: - :maxdepth: 2 - - examples.rst - extending.rst - -====================================== -Table of contents -====================================== - -.. toctree:: - :titlesonly: - - license - release - Package API - -.. faq.rst - -====================================== -Indices -====================================== - -* :ref:`genindex` -* :ref:`modindex` -* :ref:`search` diff --git a/doc/manual/source/license.rst b/doc/manual/source/license.rst deleted file mode 100644 index 7d78e94f..00000000 --- a/doc/manual/source/license.rst +++ /dev/null @@ -1,142 +0,0 @@ -.. index:: license - -License -####### - -OPEN SOURCE LICENSE AGREEMENT -============================= - -| Copyright (c) 2009-2011, University of Tennessee -| Copyright (c) 1989, 1991 Free Software Foundation, Inc. -| Copyright (c) 2006, The Regents of the University of California through - Lawrence Berkeley National Laboratory -| Copyright (c) 2014, Australian Synchrotron Research Program Inc., ("ASRP") -| Copyright (c) 2006-2007, Board of Trustees of Michigan State University -| Copyright (c) 2008-2012, The Trustees of Columbia University in - the City of New York -| Copyright (c) 2014-2019, Brookhaven Science Associates, - Brookhaven National Laboratory - - -The "DiffPy-CMI" is distributed subject to the following license conditions: - - -SOFTWARE LICENSE AGREEMENT -========================== - -Software: **DiffPy-CMI** - - -(1) The "Software", below, refers to the aforementioned DiffPy-CMI (in either -source code, or binary form and accompanying documentation). - -Part of the software was derived from the DANSE, ObjCryst++ (with permission), -PyCifRW, Python periodictable, CCTBX, and SasView open source projects, of -which the original Copyrights are contained in each individual file. - -Each licensee is addressed as "you" or "Licensee." - - -(2) The copyright holders shown above and their third-party Licensors hereby -grant licensee a royalty-free nonexclusive license, subject to the limitations -stated herein and U.S. Government license rights. - - -(3) You may modify and make a copy or copies of the software for use within -your organization, if you meet the following conditions: - - (a) Copies in source code must include the copyright notice and this - software license agreement. - - (b) Copies in binary form must include the copyright notice and this - Software License Agreement in the documentation and/or other materials - provided with the copy. - - -(4) You may modify a copy or copies of the Software or any portion of it, thus -forming a work based on the Software, and distribute copies of such work -outside your organization, if you meet all of the following conditions: - - (a) Copies in source code must include the copyright notice and this - Software License Agreement; - - (b) Copies in binary form must include the copyright notice and this - Software License Agreement in the documentation and/or other materials - provided with the copy; - - (c) Modified copies and works based on the Software must carry prominent - notices stating that you changed specified portions of the Software. - - (d) Neither the name of Brookhaven Science Associates or Brookhaven - National Laboratory nor the names of its contributors may be used to - endorse or promote products derived from this software without specific - written permission. - - -(5) Portions of the Software resulted from work developed under a U.S. -Government contract and are subject to the following license: -The Government is granted for itself and others acting on its behalf a -paid-up, nonexclusive, irrevocable worldwide license in this computer software -to reproduce, prepare derivative works, and perform publicly and display -publicly. - - -(6) WARRANTY DISCLAIMER. THE SOFTWARE IS SUPPLIED "AS IS" WITHOUT -WARRANTY OF ANY KIND. THE COPYRIGHT HOLDERS, THEIR THIRD PARTY -LICENSORS, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF ENERGY, AND -THEIR EMPLOYEES: (1) DISCLAIM ANY WARRANTIES, EXPRESS OR IMPLIED, INCLUDING -BUT NOT LIMITED TO ANY IMPLIED WARRANTIES OF MERCHANTABILITY, FITNESS FOR A -PARTICULAR PURPOSE, TITLE OR NON-INFRINGEMENT, (2) DO NOT ASSUME ANY LEGAL -LIABILITY OR RESPONSIBILITY FOR THE ACCURACY, COMPLETENESS, OR USEFULNESS OF -THE SOFTWARE, (3) DO NOT REPRESENT THAT USE OF THE SOFTWARE WOULD NOT INFRINGE -PRIVATELY OWNED RIGHTS, (4) DO NOT WARRANT THAT THE SOFTWARE WILL FUNCTION -UNINTERRUPTED, THAT IT IS ERROR-FREE OR THAT ANY ERRORS WILL BE CORRECTED. - - -(7) LIMITATION OF LIABILITY. IN NO EVENT WILL THE COPYRIGHT HOLDERS, THEIR -THIRD PARTY LICENSORS, THE UNITED STATES, THE UNITED STATES DEPARTMENT OF -ENERGY, OR THEIR EMPLOYEES: BE LIABLE FOR ANY INDIRECT, INCIDENTAL, -CONSEQUENTIAL, SPECIAL OR PUNITIVE DAMAGES OF ANY KIND OR NATURE, INCLUDING -BUT NOT LIMITED TO LOSS OF PROFITS OR LOSS OF DATA, FOR ANY REASON WHATSOEVER, -WHETHER SUCH LIABILITY IS ASSERTED ON THE BASIS OF CONTRACT, TORT (INCLUDING -NEGLIGENCE OR STRICT LIABILITY), OR OTHERWISE, EVEN IF ANY OF SAID PARTIES HAS -BEEN WARNED OF THE POSSIBILITY OF SUCH LOSS OR DAMAGES. - - -Brookhaven National Laboratory Notice -===================================== - -Acknowledgment of sponsorship ------------------------------ - -This software was produced by the Brookhaven National Laboratory, under -Contract DE-AC02-98CH10886 with the Department of Energy. - - -Government disclaimer of liability ----------------------------------- - -Neither the United States nor the United States Department of Energy, nor -any of their employees, makes any warranty, express or implied, or assumes -any legal liability or responsibility for the accuracy, completeness, or -usefulness of any data, apparatus, product, or process disclosed, or -represents that its use would not infringe privately owned rights. - - -Brookhaven disclaimer of liability ----------------------------------- - -Brookhaven National Laboratory makes no representations or warranties, -express or implied, nor assumes any liability for the use of this software. - - -Maintenance of notice ---------------------- - -In the interest of clarity regarding the origin and status of this -software, Brookhaven National Laboratory requests that any recipient of it -maintain this notice affixed to any distribution by the recipient that -contains a copy or derivative of this software. - - -.. rubric:: END OF LICENSE diff --git a/doc/manual/source/release.rst b/doc/manual/source/release.rst deleted file mode 100644 index 7ec4f81d..00000000 --- a/doc/manual/source/release.rst +++ /dev/null @@ -1,3 +0,0 @@ -.. index:: release notes - -.. mdinclude:: ../../../CHANGELOG.md diff --git a/doc/source/_static/.placeholder b/doc/source/_static/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/doc/manual/source/api/diffpy.srfit.equation.literals.rst b/doc/source/api/diffpy.srfit.equation.literals.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.equation.literals.rst rename to doc/source/api/diffpy.srfit.equation.literals.rst diff --git a/doc/manual/source/api/diffpy.srfit.equation.rst b/doc/source/api/diffpy.srfit.equation.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.equation.rst rename to doc/source/api/diffpy.srfit.equation.rst diff --git a/doc/manual/source/api/diffpy.srfit.equation.visitors.rst b/doc/source/api/diffpy.srfit.equation.visitors.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.equation.visitors.rst rename to doc/source/api/diffpy.srfit.equation.visitors.rst diff --git a/doc/source/api/diffpy.srfit.example_package.rst b/doc/source/api/diffpy.srfit.example_package.rst new file mode 100644 index 00000000..60910070 --- /dev/null +++ b/doc/source/api/diffpy.srfit.example_package.rst @@ -0,0 +1,31 @@ +.. _example_package documentation: + +|title| +======= + +.. |title| replace:: diffpy.srfit.example_package package + +.. automodule:: diffpy.srfit.example_package + :members: + :undoc-members: + :show-inheritance: + +|foo| +----- + +.. |foo| replace:: diffpy.srfit.example_package.foo module + +.. automodule:: diffpy.srfit.example_package.foo + :members: + :undoc-members: + :show-inheritance: + +|bar| +----- + +.. |bar| replace:: diffpy.srfit.example_package.bar module + +.. automodule:: diffpy.srfit.example_package.foo + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/manual/source/api/diffpy.srfit.fitbase.rst b/doc/source/api/diffpy.srfit.fitbase.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.fitbase.rst rename to doc/source/api/diffpy.srfit.fitbase.rst diff --git a/doc/manual/source/api/diffpy.srfit.interface.rst b/doc/source/api/diffpy.srfit.interface.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.interface.rst rename to doc/source/api/diffpy.srfit.interface.rst diff --git a/doc/manual/source/api/diffpy.srfit.pdf.rst b/doc/source/api/diffpy.srfit.pdf.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.pdf.rst rename to doc/source/api/diffpy.srfit.pdf.rst diff --git a/doc/source/api/diffpy.srfit.rst b/doc/source/api/diffpy.srfit.rst new file mode 100644 index 00000000..5b2b697b --- /dev/null +++ b/doc/source/api/diffpy.srfit.rst @@ -0,0 +1,30 @@ +:tocdepth: -1 + +|title| +======= + +.. |title| replace:: diffpy.srfit package + +.. automodule:: diffpy.srfit + :members: + :undoc-members: + :show-inheritance: + +Subpackages +----------- + +.. toctree:: + diffpy.srfit.example_package + +Submodules +---------- + +|module| +-------- + +.. |module| replace:: diffpy.srfit.example_submodule module + +.. automodule:: diffpy.srfit.example_submodule + :members: + :undoc-members: + :show-inheritance: diff --git a/doc/manual/source/api/diffpy.srfit.sas.rst b/doc/source/api/diffpy.srfit.sas.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.sas.rst rename to doc/source/api/diffpy.srfit.sas.rst diff --git a/doc/manual/source/api/diffpy.srfit.structure.rst b/doc/source/api/diffpy.srfit.structure.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.structure.rst rename to doc/source/api/diffpy.srfit.structure.rst diff --git a/doc/manual/source/api/diffpy.srfit.util.rst b/doc/source/api/diffpy.srfit.util.rst similarity index 100% rename from doc/manual/source/api/diffpy.srfit.util.rst rename to doc/source/api/diffpy.srfit.util.rst diff --git a/doc/manual/source/conf.py b/doc/source/conf.py similarity index 81% rename from doc/manual/source/conf.py rename to doc/source/conf.py index c3cbddc0..e7654b23 100644 --- a/doc/manual/source/conf.py +++ b/doc/source/conf.py @@ -2,9 +2,10 @@ # -*- coding: utf-8 -*- # # diffpy.srfit documentation build configuration file, created by -# sphinx-quickstart on Fri Dec 6 18:09:01 2013. +# sphinx-quickstart on Thu Jan 30 15:49:41 2014. # -# This file is execfile()d with the current directory set to its containing dir. +# 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. @@ -12,32 +13,36 @@ # All configuration values have a default; values that are commented out # serve to show the default. -import os import sys import time - -from setup import versiondata +from importlib.metadata import version +from pathlib import Path # 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. -# sys.path.insert(0, os.path.abspath('.')) -# sys.path.insert(0, os.path.abspath('../../..')) +# 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 = "Christopher L. Farrow, Pavol Juhás, Simon J.L. Billinge group" +ab_authors = "Billinge Group members and community contributors" -# -- General configuration ----------------------------------------------------- +# -- 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. +# 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", ] @@ -57,15 +62,13 @@ # General information about the project. project = "diffpy.srfit" -copyright = "%Y, Brookhaven National Laboratory" +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. -sys.path.insert(0, os.path.abspath("../../..")) - -fullversion = versiondata.get("DEFAULT", "version") +fullversion = version(project) # The short X.Y version. version = "".join(fullversion.split(".post")[:1]) # The full version, including alpha/beta/rc tags. @@ -78,8 +81,7 @@ # There are two options for replacing |today|: either, you set today to some # non-false value, then it is used: # today = '' -today_seconds = versiondata.getint("DEFAULT", "timestamp") -today = time.strftime("%B %d, %Y", time.localtime(today_seconds)) +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' @@ -88,9 +90,10 @@ # List of patterns, relative to source directory, that match files and # directories to ignore when looking for source files. -exclude_patterns = [] +exclude_patterns = ["build"] -# The reST default role (used for this markup: `text`) to use for all documents. +# 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. @@ -108,22 +111,23 @@ pygments_style = "sphinx" # A list of ignored prefixes for module index sorting. -modindex_common_prefix = ["diffpy.srfit."] +modindex_common_prefix = ["diffpy.srfit"] # Display all warnings for missing links. nitpicky = True -# -- Options for HTML output --------------------------------------------------- +# -- 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_py3doc_enhanced_theme" +# +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 = { - "collapsiblesidebar": "true", "navigation_with_keys": "true", } @@ -151,6 +155,11 @@ # 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' @@ -173,7 +182,7 @@ # html_use_index = True # If true, the index is split into individual pages for each letter. -html_split_index = True +# html_split_index = False # If true, links to the reST sources are added to the pages. # html_show_sourcelink = True @@ -193,10 +202,11 @@ # html_file_suffix = None # Output file base name for HTML help builder. -htmlhelp_basename = "srfitdoc" +basename = "diffpy.srfit".replace(" ", "").replace(".", "") +htmlhelp_basename = basename + "doc" -# -- Options for LaTeX output -------------------------------------------------- +# -- Options for LaTeX output --------------------------------------------- latex_elements = { # The paper size ('letterpaper' or 'a4paper'). @@ -208,9 +218,10 @@ } # Grouping the document tree into LaTeX files. List of tuples -# (source start file, target name, title, author, documentclass [howto/manual]). +# (source start file, target name, title, +# author, documentclass [howto, manual, or own class]). latex_documents = [ - ("index", "srfit_manual.tex", "diffpy.srfit documentation", ab_authors, "manual"), + ("index", "diffpy.srfit.tex", "diffpy.srfit Documentation", ab_authors, "manual"), ] # The name of an image file (relative to this directory) to place at the top of @@ -234,17 +245,17 @@ # latex_domain_indices = True -# -- Options for manual page output -------------------------------------------- +# -- 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.srfit", "diffpy.srfit documentation", ab_authors, 1)] +man_pages = [("index", "diffpy.srfit", "diffpy.srfit Documentation", ab_authors, 1)] # If true, show URL addresses after external links. # man_show_urls = False -# -- Options for Texinfo output ------------------------------------------------ +# -- Options for Texinfo output ------------------------------------------- # Grouping the document tree into Texinfo files. List of tuples # (source start file, target name, title, author, @@ -253,7 +264,7 @@ ( "index", "diffpy.srfit", - "diffpy.srfit documentation", + "diffpy.srfit Documentation", ab_authors, "diffpy.srfit", "One line description of project.", @@ -270,9 +281,9 @@ # 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 = { - "numpy": ("https://docs.scipy.org/doc/numpy", None), - "python": ("https://docs.python.org/3.7", None), -} +# intersphinx_mapping = {'http://docs.python.org/': None} diff --git a/doc/manual/source/examples.rst b/doc/source/examples.rst similarity index 100% rename from doc/manual/source/examples.rst rename to doc/source/examples.rst diff --git a/doc/manual/source/examples/coreshellnp.rst b/doc/source/examples/coreshellnp.rst similarity index 100% rename from doc/manual/source/examples/coreshellnp.rst rename to doc/source/examples/coreshellnp.rst diff --git a/doc/manual/source/examples/crystalpdf.rst b/doc/source/examples/crystalpdf.rst similarity index 100% rename from doc/manual/source/examples/crystalpdf.rst rename to doc/source/examples/crystalpdf.rst diff --git a/doc/manual/source/examples/crystalpdfall.rst b/doc/source/examples/crystalpdfall.rst similarity index 100% rename from doc/manual/source/examples/crystalpdfall.rst rename to doc/source/examples/crystalpdfall.rst diff --git a/doc/manual/source/examples/crystalpdfobjcryst.rst b/doc/source/examples/crystalpdfobjcryst.rst similarity index 100% rename from doc/manual/source/examples/crystalpdfobjcryst.rst rename to doc/source/examples/crystalpdfobjcryst.rst diff --git a/doc/manual/source/examples/crystalpdftwodata.rst b/doc/source/examples/crystalpdftwodata.rst similarity index 100% rename from doc/manual/source/examples/crystalpdftwodata.rst rename to doc/source/examples/crystalpdftwodata.rst diff --git a/doc/manual/source/examples/crystalpdftwophase.rst b/doc/source/examples/crystalpdftwophase.rst similarity index 100% rename from doc/manual/source/examples/crystalpdftwophase.rst rename to doc/source/examples/crystalpdftwophase.rst diff --git a/doc/manual/source/examples/debyemodel.rst b/doc/source/examples/debyemodel.rst similarity index 100% rename from doc/manual/source/examples/debyemodel.rst rename to doc/source/examples/debyemodel.rst diff --git a/doc/manual/source/examples/debyemodelII.rst b/doc/source/examples/debyemodelII.rst similarity index 100% rename from doc/manual/source/examples/debyemodelII.rst rename to doc/source/examples/debyemodelII.rst diff --git a/doc/manual/source/examples/ellipsoidsas.rst b/doc/source/examples/ellipsoidsas.rst similarity index 100% rename from doc/manual/source/examples/ellipsoidsas.rst rename to doc/source/examples/ellipsoidsas.rst diff --git a/doc/manual/source/examples/gaussiangenerator.rst b/doc/source/examples/gaussiangenerator.rst similarity index 100% rename from doc/manual/source/examples/gaussiangenerator.rst rename to doc/source/examples/gaussiangenerator.rst diff --git a/doc/manual/source/examples/gaussianrecipe.rst b/doc/source/examples/gaussianrecipe.rst similarity index 100% rename from doc/manual/source/examples/gaussianrecipe.rst rename to doc/source/examples/gaussianrecipe.rst diff --git a/doc/manual/source/examples/interface.rst b/doc/source/examples/interface.rst similarity index 100% rename from doc/manual/source/examples/interface.rst rename to doc/source/examples/interface.rst diff --git a/doc/manual/source/examples/npintensity.rst b/doc/source/examples/npintensity.rst similarity index 100% rename from doc/manual/source/examples/npintensity.rst rename to doc/source/examples/npintensity.rst diff --git a/doc/manual/source/examples/npintensityII.rst b/doc/source/examples/npintensityII.rst similarity index 100% rename from doc/manual/source/examples/npintensityII.rst rename to doc/source/examples/npintensityII.rst diff --git a/doc/manual/source/examples/nppdfcrystal.rst b/doc/source/examples/nppdfcrystal.rst similarity index 100% rename from doc/manual/source/examples/nppdfcrystal.rst rename to doc/source/examples/nppdfcrystal.rst diff --git a/doc/manual/source/examples/nppdfobjcryst.rst b/doc/source/examples/nppdfobjcryst.rst similarity index 100% rename from doc/manual/source/examples/nppdfobjcryst.rst rename to doc/source/examples/nppdfobjcryst.rst diff --git a/doc/manual/source/examples/nppdfsas.rst b/doc/source/examples/nppdfsas.rst similarity index 100% rename from doc/manual/source/examples/nppdfsas.rst rename to doc/source/examples/nppdfsas.rst diff --git a/doc/manual/source/examples/simplepdf.rst b/doc/source/examples/simplepdf.rst similarity index 100% rename from doc/manual/source/examples/simplepdf.rst rename to doc/source/examples/simplepdf.rst diff --git a/doc/manual/source/examples/simplepdftwophase.rst b/doc/source/examples/simplepdftwophase.rst similarity index 100% rename from doc/manual/source/examples/simplepdftwophase.rst rename to doc/source/examples/simplepdftwophase.rst diff --git a/doc/manual/source/examples/simplerecipe.rst b/doc/source/examples/simplerecipe.rst similarity index 100% rename from doc/manual/source/examples/simplerecipe.rst rename to doc/source/examples/simplerecipe.rst diff --git a/doc/manual/source/extending.rst b/doc/source/extending.rst similarity index 100% rename from doc/manual/source/extending.rst rename to doc/source/extending.rst diff --git a/doc/source/index.rst b/doc/source/index.rst new file mode 100644 index 00000000..85139071 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,44 @@ +####### +|title| +####### + +.. |title| replace:: diffpy.srfit documentation + +diffpy.srfit - A Python package package for building a global optimizer on the fly from components such as function calculators, regression algorithms, and structure models.. + +| Software version |release|. +| Last updated |today|. + +======= +Authors +======= + +diffpy.srfit is developed by Billinge Group +and its community contributors. + +For a detailed list of contributors see +https://github.com/diffpy/diffpy.srfit/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/source/license.rst b/doc/source/license.rst new file mode 100644 index 00000000..cfab61c2 --- /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/source/release.rst b/doc/source/release.rst new file mode 100644 index 00000000..27cd0cc9 --- /dev/null +++ b/doc/source/release.rst @@ -0,0 +1,5 @@ +:tocdepth: -1 + +.. index:: release notes + +.. include:: ../../CHANGELOG.rst diff --git a/environment.yml b/environment.yml new file mode 100644 index 00000000..0e279fbf --- /dev/null +++ b/environment.yml @@ -0,0 +1,6 @@ +name: diffpy.srfit +channels: + - conda-forge +dependencies: + - python=3 + - pip diff --git a/news/TEMPLATE.rst b/news/TEMPLATE.rst new file mode 100644 index 00000000..790d30b1 --- /dev/null +++ b/news/TEMPLATE.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* + +**Security:** + +* diff --git a/requirements/README.txt b/requirements/README.txt new file mode 100644 index 00000000..dc34909d --- /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 00000000..e69de29b diff --git a/requirements/docs.txt b/requirements/docs.txt new file mode 100644 index 00000000..ab17b1c8 --- /dev/null +++ b/requirements/docs.txt @@ -0,0 +1,4 @@ +sphinx +sphinx_rtd_theme +doctr +m2r diff --git a/requirements/pip.txt b/requirements/pip.txt new file mode 100644 index 00000000..e69de29b diff --git a/requirements/run.txt b/requirements/run.txt new file mode 100644 index 00000000..e69de29b diff --git a/requirements/test.txt b/requirements/test.txt new file mode 100644 index 00000000..6f9ccf84 --- /dev/null +++ b/requirements/test.txt @@ -0,0 +1,5 @@ +flake8 +pytest +codecov +coverage +pytest-env diff --git a/src/diffpy/srfit/tests/testpdf.py b/src/diffpy/srfit/tests/testpdf.py index fc1c53ab..41f04238 100644 --- a/src/diffpy/srfit/tests/testpdf.py +++ b/src/diffpy/srfit/tests/testpdf.py @@ -23,13 +23,7 @@ from diffpy.srfit.exceptions import SrFitError from diffpy.srfit.pdf import PDFContribution, PDFGenerator, PDFParser -from diffpy.srfit.tests.utils import ( - _msg_nosrreal, - _msg_nostructure, - datafile, - has_srreal, - has_structure, -) +from diffpy.srfit.tests.utils import _msg_nosrreal, _msg_nostructure, datafile, has_srreal, has_structure # ---------------------------------------------------------------------------- diff --git a/src/diffpy/srfit/tests/testrecipeorganizer.py b/src/diffpy/srfit/tests/testrecipeorganizer.py index 0616f795..002b6d82 100644 --- a/src/diffpy/srfit/tests/testrecipeorganizer.py +++ b/src/diffpy/srfit/tests/testrecipeorganizer.py @@ -22,11 +22,7 @@ from diffpy.srfit.equation.builder import EquationFactory from diffpy.srfit.fitbase.calculator import Calculator from diffpy.srfit.fitbase.parameter import Parameter -from diffpy.srfit.fitbase.recipeorganizer import ( - RecipeContainer, - RecipeOrganizer, - equationFromString, -) +from diffpy.srfit.fitbase.recipeorganizer import RecipeContainer, RecipeOrganizer, equationFromString from diffpy.srfit.tests.utils import capturestdout # ---------------------------------------------------------------------------- diff --git a/src/diffpy/srfit/tests/testsgconstraints.py b/src/diffpy/srfit/tests/testsgconstraints.py index 60daa7d5..f1d9039f 100644 --- a/src/diffpy/srfit/tests/testsgconstraints.py +++ b/src/diffpy/srfit/tests/testsgconstraints.py @@ -19,13 +19,7 @@ import numpy -from diffpy.srfit.tests.utils import ( - _msg_nopyobjcryst, - _msg_nostructure, - datafile, - has_pyobjcryst, - has_structure, -) +from diffpy.srfit.tests.utils import _msg_nopyobjcryst, _msg_nostructure, datafile, has_pyobjcryst, has_structure # ---------------------------------------------------------------------------- diff --git a/tests/conftest.py b/tests/conftest.py new file mode 100644 index 00000000..e3b63139 --- /dev/null +++ b/tests/conftest.py @@ -0,0 +1,19 @@ +import json +from pathlib import Path + +import pytest + + +@pytest.fixture +def user_filesystem(tmp_path): + base_dir = Path(tmp_path) + home_dir = base_dir / "home_dir" + home_dir.mkdir(parents=True, exist_ok=True) + cwd_dir = base_dir / "cwd_dir" + cwd_dir.mkdir(parents=True, exist_ok=True) + + home_config_data = {"username": "home_username", "email": "home@email.com"} + with open(home_dir / "diffpyconfig.json", "w") as f: + json.dump(home_config_data, f) + + yield tmp_path