From d39431edcb7283afd8644f752252a8327bb44f13 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:35:16 -0400 Subject: [PATCH 01/13] Add doc --- .github/workflows/check-news-item.yml | 12 + .../matrix-and-codecov-on-merge-to-main.yml | 21 ++ .github/workflows/publish-docs-on-release.yml | 14 + .gitignore | 89 ++++-- doc/Makefile | 223 ++++++++++++-- doc/examples/npintensity.py | 8 +- doc/make.bat | 36 +++ doc/source/_static/.placeholder | 0 .../api/diffpy.srfit.equation.literals.rst | 45 +++ doc/source/api/diffpy.srfit.equation.rst | 38 +++ .../api/diffpy.srfit.equation.visitors.rst | 53 ++++ doc/source/api/diffpy.srfit.fitbase.rst | 141 +++++++++ doc/source/api/diffpy.srfit.interface.rst | 21 ++ doc/source/api/diffpy.srfit.pdf.rst | 61 ++++ doc/source/api/diffpy.srfit.rst | 35 +++ doc/source/api/diffpy.srfit.sas.rst | 61 ++++ doc/source/api/diffpy.srfit.structure.rst | 69 +++++ doc/source/api/diffpy.srfit.util.rst | 61 ++++ doc/source/conf.py | 289 ++++++++++++++++++ doc/source/index.rst | 44 +++ doc/source/license.rst | 39 +++ doc/source/release.rst | 5 + 22 files changed, 1310 insertions(+), 55 deletions(-) create mode 100644 .github/workflows/check-news-item.yml create mode 100644 .github/workflows/matrix-and-codecov-on-merge-to-main.yml create mode 100644 .github/workflows/publish-docs-on-release.yml create mode 100644 doc/make.bat create mode 100644 doc/source/_static/.placeholder create mode 100644 doc/source/api/diffpy.srfit.equation.literals.rst create mode 100644 doc/source/api/diffpy.srfit.equation.rst create mode 100644 doc/source/api/diffpy.srfit.equation.visitors.rst create mode 100644 doc/source/api/diffpy.srfit.fitbase.rst create mode 100644 doc/source/api/diffpy.srfit.interface.rst create mode 100644 doc/source/api/diffpy.srfit.pdf.rst create mode 100644 doc/source/api/diffpy.srfit.rst create mode 100644 doc/source/api/diffpy.srfit.sas.rst create mode 100644 doc/source/api/diffpy.srfit.structure.rst create mode 100644 doc/source/api/diffpy.srfit.util.rst create mode 100644 doc/source/conf.py create mode 100644 doc/source/index.rst create mode 100644 doc/source/license.rst create mode 100644 doc/source/release.rst diff --git a/.github/workflows/check-news-item.yml b/.github/workflows/check-news-item.yml new file mode 100644 index 00000000..9d696ef9 --- /dev/null +++ b/.github/workflows/check-news-item.yml @@ -0,0 +1,12 @@ +name: Check for News + +on: + pull_request_target: + branches: + - main + +jobs: + build: + uses: Billingegroup/release-scripts/.github/workflows/_check-news-item.yml@v0 + with: + project: diffpy.srfit diff --git a/.github/workflows/matrix-and-codecov-on-merge-to-main.yml b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml new file mode 100644 index 00000000..01dcfbb5 --- /dev/null +++ b/.github/workflows/matrix-and-codecov-on-merge-to-main.yml @@ -0,0 +1,21 @@ +name: CI + +on: + push: + branches: + - main + release: + types: + - prereleased + - published + workflow_dispatch: + +jobs: + coverage: + uses: Billingegroup/release-scripts/.github/workflows/_matrix-and-codecov-on-merge-to-main.yml@v0 + with: + project: diffpy.srfit + c_extension: false + headless: false + secrets: + CODECOV_TOKEN: ${{ secrets.CODECOV_TOKEN }} diff --git a/.github/workflows/publish-docs-on-release.yml b/.github/workflows/publish-docs-on-release.yml new file mode 100644 index 00000000..993d589b --- /dev/null +++ b/.github/workflows/publish-docs-on-release.yml @@ -0,0 +1,14 @@ +name: Build and Deploy Docs + +on: + release: + types: + - published + workflow_dispatch: + +jobs: + docs: + uses: Billingegroup/release-scripts/.github/workflows/_publish-docs-on-release.yml@v0 + with: + project: diffpy.srfit + c_extension: false diff --git a/.gitignore b/.gitignore index 9f5ecbf0..a25212ea 100644 --- a/.gitignore +++ b/.gitignore @@ -1,44 +1,99 @@ +# Byte-compiled / optimized / DLL files +__pycache__/ *.py[cod] +*$py.class # C extensions *.so -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -temp -develop-eggs +# Distribution / packaging +.Python +env/ +build/ +develop-eggs/ +dist/ +downloads/ +eggs/ +.eggs/ +lib/ +lib64/ +parts/ +sdist/ +var/ +venv/ +*.egg-info/ .installed.cfg -lib -lib64 -tags +*.egg +bin/ +temp/ +tags/ errors.err +# PyInstaller +# Usually these files are written by a python script from a template +# before PyInstaller builds the exe, so as to inject date/other infos into it. +*.manifest +*.spec + # Installer logs pip-log.txt +pip-delete-this-directory.txt MANIFEST # Unit test / coverage reports +htmlcov/ +.tox/ .coverage -.tox +.coverage.* +.cache nosetests.xml +coverage.xml +*,cover +.hypothesis/ # Translations *.mo +*.pot # Mr Developer .mr.developer.cfg .project .pydevproject -.settings + +# Django stuff: +*.log + +# Sphinx documentation +docs/build/ +docs/source/generated/ + +# pytest +.pytest_cache/ + +# PyBuilder +target/ + +# Editor files +# mac +.DS_Store +*~ + +# vim +*.swp +*.swo + +# pycharm +.idea/ + +# VSCode +.vscode/ + +# Ipython Notebook +.ipynb_checkpoints # version information setup.cfg /src/diffpy/*/version.cfg + +# Rever +rever/ 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..2be83069 --- /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/source/_static/.placeholder b/doc/source/_static/.placeholder new file mode 100644 index 00000000..e69de29b diff --git a/doc/source/api/diffpy.srfit.equation.literals.rst b/doc/source/api/diffpy.srfit.equation.literals.rst new file mode 100644 index 00000000..6875b5ef --- /dev/null +++ b/doc/source/api/diffpy.srfit.equation.literals.rst @@ -0,0 +1,45 @@ +:tocdepth: -1 + +diffpy.srfit.equation.literals package +====================================== + +.. automodule:: diffpy.srfit.equation.literals + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.equation.literals.argument module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.literals.argument + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.literals.abcs module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.literals.abcs + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.literals.literal module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.literals.literal + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.literals.operators module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.literals.operators + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.equation.rst b/doc/source/api/diffpy.srfit.equation.rst new file mode 100644 index 00000000..f7a47192 --- /dev/null +++ b/doc/source/api/diffpy.srfit.equation.rst @@ -0,0 +1,38 @@ +:tocdepth: -1 + +diffpy.srfit.equation package +============================= + +.. automodule:: diffpy.srfit.equation + :members: + :undoc-members: + :show-inheritance: + +Subpackages +----------- + +.. toctree:: + :titlesonly: + + diffpy.srfit.equation.visitors + diffpy.srfit.equation.literals + +Submodules +---------- + +diffpy.srfit.equation.builder module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.builder + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.equationmod module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.equationmod + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.equation.visitors.rst b/doc/source/api/diffpy.srfit.equation.visitors.rst new file mode 100644 index 00000000..54e10bc6 --- /dev/null +++ b/doc/source/api/diffpy.srfit.equation.visitors.rst @@ -0,0 +1,53 @@ +:tocdepth: -1 + +diffpy.srfit.equation.visitors package +====================================== + +.. automodule:: diffpy.srfit.equation.visitors + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.equation.visitors.validator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.visitors.validator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.visitors.swapper module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.visitors.swapper + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.visitors.argfinder module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.visitors.argfinder + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.visitors.visitor module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.visitors.visitor + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.equation.visitors.printer module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.equation.visitors.printer + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.fitbase.rst b/doc/source/api/diffpy.srfit.fitbase.rst new file mode 100644 index 00000000..5c092c9f --- /dev/null +++ b/doc/source/api/diffpy.srfit.fitbase.rst @@ -0,0 +1,141 @@ +:tocdepth: -1 + +diffpy.srfit.fitbase package +============================ + +.. automodule:: diffpy.srfit.fitbase + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.fitbase.simplerecipe module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.simplerecipe + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.constraint module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.constraint + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.fithook module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.fithook + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.fitresults module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.fitresults + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.profilegenerator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.profilegenerator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.validatable module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.validatable + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.configurable module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.configurable + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.profile module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.profile + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.restraint module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.restraint + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.fitcontribution module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.fitcontribution + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.recipeorganizer module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.recipeorganizer + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.fitrecipe module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.fitrecipe + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.parameterset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.parameterset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.calculator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.calculator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.parameter module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.parameter + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.fitbase.profileparser module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.fitbase.profileparser + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.interface.rst b/doc/source/api/diffpy.srfit.interface.rst new file mode 100644 index 00000000..40b829d7 --- /dev/null +++ b/doc/source/api/diffpy.srfit.interface.rst @@ -0,0 +1,21 @@ +:tocdepth: -1 + +diffpy.srfit.interface package +============================== + +.. automodule:: diffpy.srfit.interface + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.interface.interface module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.interface.interface + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.pdf.rst b/doc/source/api/diffpy.srfit.pdf.rst new file mode 100644 index 00000000..60f3e947 --- /dev/null +++ b/doc/source/api/diffpy.srfit.pdf.rst @@ -0,0 +1,61 @@ +:tocdepth: -1 + +diffpy.srfit.pdf package +======================== + +.. automodule:: diffpy.srfit.pdf + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.pdf.debyepdfgenerator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.debyepdfgenerator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.pdf.characteristicfunctions module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.characteristicfunctions + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.pdf.pdfparser module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.pdfparser + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.pdf.pdfgenerator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.pdfgenerator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.pdf.basepdfgenerator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.basepdfgenerator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.pdf.pdfcontribution module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.pdf.pdfcontribution + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.rst b/doc/source/api/diffpy.srfit.rst new file mode 100644 index 00000000..9eef9e38 --- /dev/null +++ b/doc/source/api/diffpy.srfit.rst @@ -0,0 +1,35 @@ +:tocdepth: -1 + +diffpy.srfit package +==================== + +.. automodule:: diffpy.srfit + :members: + :undoc-members: + :show-inheritance: + +Subpackages +----------- + +.. toctree:: + :titlesonly: + + diffpy.srfit.interface + diffpy.srfit.equation + diffpy.srfit.util + diffpy.srfit.pdf + diffpy.srfit.sas + diffpy.srfit.fitbase + diffpy.srfit.structure + +Submodules +---------- + +diffpy.srfit.exceptions module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.exceptions + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.sas.rst b/doc/source/api/diffpy.srfit.sas.rst new file mode 100644 index 00000000..fbc67925 --- /dev/null +++ b/doc/source/api/diffpy.srfit.sas.rst @@ -0,0 +1,61 @@ +:tocdepth: -1 + +diffpy.srfit.sas package +======================== + +.. automodule:: diffpy.srfit.sas + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.sas.sasparser module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.sasparser + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.sas.prcalculator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.prcalculator + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.sas.sasprofile module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.sasprofile + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.sas.sasparameter module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.sasparameter + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.sas.sasimport module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.sasimport + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.sas.sasgenerator module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.sas.sasgenerator + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.structure.rst b/doc/source/api/diffpy.srfit.structure.rst new file mode 100644 index 00000000..1fa5326d --- /dev/null +++ b/doc/source/api/diffpy.srfit.structure.rst @@ -0,0 +1,69 @@ +:tocdepth: -1 + +diffpy.srfit.structure package +============================== + +.. automodule:: diffpy.srfit.structure + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.structure.objcrystparset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.objcrystparset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.basestructureparset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.basestructureparset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.srrealparset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.srrealparset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.diffpyparset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.diffpyparset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.cctbxparset module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.cctbxparset + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.bvsrestraint module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.bvsrestraint + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.structure.sgconstraints module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.structure.sgconstraints + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/api/diffpy.srfit.util.rst b/doc/source/api/diffpy.srfit.util.rst new file mode 100644 index 00000000..b96e6945 --- /dev/null +++ b/doc/source/api/diffpy.srfit.util.rst @@ -0,0 +1,61 @@ +:tocdepth: -1 + +diffpy.srfit.util package +========================= + +.. automodule:: diffpy.srfit.util + :members: + :undoc-members: + :show-inheritance: + +Submodules +---------- + +diffpy.srfit.util.inpututils module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.inpututils + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.util.observable module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.observable + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.util.tagmanager module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.tagmanager + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.util.argbinders module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.argbinders + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.util.nameutils module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.nameutils + :members: + :undoc-members: + :show-inheritance: + +diffpy.srfit.util.weakrefcallable module +^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +.. automodule:: diffpy.srfit.util.weakrefcallable + :members: + :undoc-members: + :show-inheritance: + diff --git a/doc/source/conf.py b/doc/source/conf.py new file mode 100644 index 00000000..e7654b23 --- /dev/null +++ b/doc/source/conf.py @@ -0,0 +1,289 @@ +#!/usr/bin/env python +# -*- coding: utf-8 -*- +# +# diffpy.srfit 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 + +# 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.srfit" +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.srfit"] + +# 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.srfit".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.srfit.tex", "diffpy.srfit 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.srfit", "diffpy.srfit 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.srfit", + "diffpy.srfit Documentation", + ab_authors, + "diffpy.srfit", + "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 00000000..d7ca0de9 --- /dev/null +++ b/doc/source/index.rst @@ -0,0 +1,44 @@ +####### +|title| +####### + +.. |title| replace:: diffpy.srfit documentation + +diffpy.srfit - Python package for structure refinement from diffraction data.. + +| 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..9ae52a98 --- /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 From 8af2e9bcc204bb9a14713775c76d93bfc5cd0c51 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:35:35 -0400 Subject: [PATCH 02/13] Add src --- src/diffpy/__init__.py | 20 ++++------ src/diffpy/srfit/__init__.py | 20 +++++----- src/diffpy/srfit/equation/builder.py | 8 ++-- src/diffpy/srfit/interface/__init__.py | 6 +-- src/diffpy/srfit/structure/__init__.py | 10 ++--- src/diffpy/srfit/version.py | 54 +++++++------------------- 6 files changed, 41 insertions(+), 77 deletions(-) diff --git a/src/diffpy/__init__.py b/src/diffpy/__init__.py index edc2c425..903acd5f 100644 --- a/src/diffpy/__init__.py +++ b/src/diffpy/__init__.py @@ -1,27 +1,23 @@ #!/usr/bin/env python ############################################################################## # -# diffpy by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2008 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: Chris Farrow +# 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.srfit/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 __path__ = extend_path(__path__, __name__) - # End of file diff --git a/src/diffpy/srfit/__init__.py b/src/diffpy/srfit/__init__.py index 76d70de4..5b0425f6 100644 --- a/src/diffpy/srfit/__init__.py +++ b/src/diffpy/srfit/__init__.py @@ -1,18 +1,19 @@ #!/usr/bin/env python ############################################################################## # -# diffpy.srfit by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2008 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: Chris Farrow +# 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.srfit/graphs/contributors +# +# See LICENSE.rst for license information. # ############################################################################## + """Complex modeling framework for structure refinement and solution. SrFit is a tool for coherently combining known information about a material to @@ -31,9 +32,10 @@ learn how to use and customize the various parts of SrFit. """ -__all__ = ["__version__"] - # package version from diffpy.srfit.version import __version__ +# silence the pyflakes syntax checker +assert __version__ or True + # End of file diff --git a/src/diffpy/srfit/equation/builder.py b/src/diffpy/srfit/equation/builder.py index 22e68d91..01db6667 100644 --- a/src/diffpy/srfit/equation/builder.py +++ b/src/diffpy/srfit/equation/builder.py @@ -666,10 +666,10 @@ def __wrapSrFitOperators(): def is_exported_type(cls): """Check if the class should be wrapped as OperatorBuilder.""" return ( - inspect.isclass(cls) and - issubclass(cls, opmod.Operator) and - not inspect.isabstract(cls) and - cls not in excluded_types + inspect.isclass(cls) + and issubclass(cls, opmod.Operator) + and not inspect.isabstract(cls) + and cls not in excluded_types ) # create OperatorBuilder objects diff --git a/src/diffpy/srfit/interface/__init__.py b/src/diffpy/srfit/interface/__init__.py index d3675428..416b3354 100644 --- a/src/diffpy/srfit/interface/__init__.py +++ b/src/diffpy/srfit/interface/__init__.py @@ -21,16 +21,12 @@ """ -from diffpy.srfit.interface.interface import ParameterInterface +from diffpy.srfit.interface.interface import FitRecipeInterface, ParameterInterface, RecipeOrganizerInterface _parameter_interface = ParameterInterface -from diffpy.srfit.interface.interface import RecipeOrganizerInterface - _recipeorganizer_interface = RecipeOrganizerInterface -from diffpy.srfit.interface.interface import FitRecipeInterface - _fitrecipe_interface = FitRecipeInterface # End of file diff --git a/src/diffpy/srfit/structure/__init__.py b/src/diffpy/srfit/structure/__init__.py index 5904f06f..cf24d47c 100644 --- a/src/diffpy/srfit/structure/__init__.py +++ b/src/diffpy/srfit/structure/__init__.py @@ -17,6 +17,10 @@ interface and automatic structure constraint generation from space group information. """ +from diffpy.srfit.structure.sgconstraints import constrainAsSpaceGroup + +# silence pyflakes checker +assert constrainAsSpaceGroup def struToParameterSet(name, stru): @@ -54,10 +58,4 @@ def struToParameterSet(name, stru): raise TypeError("Unadaptable structure format") -from diffpy.srfit.structure.sgconstraints import constrainAsSpaceGroup - -# silence pyflakes checker -assert constrainAsSpaceGroup - - # End of file diff --git a/src/diffpy/srfit/version.py b/src/diffpy/srfit/version.py index f34867c2..e8d23296 100644 --- a/src/diffpy/srfit/version.py +++ b/src/diffpy/srfit/version.py @@ -1,54 +1,26 @@ #!/usr/bin/env python ############################################################################## # -# diffpy.srfit by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2008 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: Chris Farrow +# 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.srfit/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 pkg_resources import resource_filename - -# obtain version information from the version.cfg file -cp = dict(version="", date="", commit="", timestamp="0") -fcfg = resource_filename(__name__, "version.cfg") -if not os.path.isfile(fcfg): # pragma: no cover - from warnings import warn - - warn('Package metadata not found, execute "./setup.py egg_info".') - 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) +"""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, fcfg, fp, kwords +__version__ = version("diffpy.srfit") # End of file From bc929066c90879228549deff8e709b1a71774593 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:36:01 -0400 Subject: [PATCH 03/13] Add license --- LICENSE.txt => LICENSE.rst | 0 LICENSE_DANSE.rst | 50 ++++++++++++++++++++++++++++++++++++++ 2 files changed, 50 insertions(+) rename LICENSE.txt => LICENSE.rst (100%) create mode 100644 LICENSE_DANSE.rst diff --git a/LICENSE.txt b/LICENSE.rst similarity index 100% rename from LICENSE.txt rename to LICENSE.rst diff --git a/LICENSE_DANSE.rst b/LICENSE_DANSE.rst new file mode 100644 index 00000000..d56af619 --- /dev/null +++ b/LICENSE_DANSE.rst @@ -0,0 +1,50 @@ +LICENSE +======= + +This program is part of the DiffPy and DANSE open-source projects +and is available subject to the conditions and terms laid out below. + +Copyright 2006-2007, Board of Trustees of Michigan State University, + +Copyright 2008-2012, The Trustees of Columbia University in the +City of New York. (Copyright holder indicated in each source file). + +Copyright (c) 2024, The Trustees of Columbia University in the City of New York. +All rights reserved. + +For more information please visit the project web-page: + + http://www.diffpy.org/ + +or email Prof. Simon Billinge at sb2896@columbia.edu + +Redistribution and use in source and binary forms, with or without +modification, are permitted provided that the following conditions +are met: + +- Redistributions of source code must retain the above copyright + notice, this list of conditions and the following disclaimer. + +- 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. + +- 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 COPYRIGHT HOLDER "AS IS". COPYRIGHT HOLDER +EXPRESSLY DISCLAIMS ANY AND ALL WARRANTIES AND CONDITIONS, EITHER +EXPRESS OR IMPLIED, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED +WARRANTIES OF MERCHANTABILITY, TITLE, FITNESS, ADEQUACY OR SUITABILITY +FOR A PARTICULAR PURPOSE, AND ANY WARRANTIES OF FREEDOM FROM +INFRINGEMENT OF ANY DOMESTIC OR FOREIGN PATENT, COPYRIGHTS, TRADE +SECRETS OR OTHER PROPRIETARY RIGHTS OF ANY PARTY. IN NO EVENT SHALL +COPYRIGHT HOLDER BE LIABLE TO ANY PARTY 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 OR RELATING TO THIS AGREEMENT, EVEN IF ADVISED OF THE +POSSIBILITY OF SUCH DAMAGE. From 78d10486b1435ce60be7b9d447314f11cc57d5ac Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:37:39 -0400 Subject: [PATCH 04/13] Add tests, iosrt, flake8, codecov --- .codecov.yml | 5 +++-- .flake8 | 9 ++------- .isort.cfg | 4 ++++ .pre-commit-config.yaml | 25 +++++++++++++------------ LICENSE_DANSE.txt | 34 ---------------------------------- news/TEMPLATE.rst | 23 +++++++++++++++++++++++ tests/conftest.py | 19 +++++++++++++++++++ tests/test_recipeorganizer.py | 6 +----- tests/test_sgconstraints.py | 8 +------- tests/test_version.py | 10 ++++++++++ 10 files changed, 76 insertions(+), 67 deletions(-) create mode 100644 .isort.cfg delete mode 100644 LICENSE_DANSE.txt create mode 100644 news/TEMPLATE.rst create mode 100644 tests/conftest.py create mode 100644 tests/test_version.py diff --git a/.codecov.yml b/.codecov.yml index 70686df3..04dd6510 100644 --- a/.codecov.yml +++ b/.codecov.yml @@ -10,7 +10,7 @@ coverage: status: patch: default: - target: '80' + target: '70' if_no_uploads: error if_not_found: success if_ci_failed: failure @@ -20,12 +20,13 @@ coverage: target: auto if_no_uploads: error if_not_found: success - if_ci_failed: failure + if_ci_failed: error paths: '!*/tests/.*' tests: target: 97.9% paths: '*/tests/.*' + if_not_found: success flags: tests: diff --git a/.flake8 b/.flake8 index 19f45e36..2d2cb168 100644 --- a/.flake8 +++ b/.flake8 @@ -4,13 +4,8 @@ exclude = __pycache__, build, dist, - doc/source/conf.py, - */doc/source/conf.py, - hooks/post_gen_project.py, - */__init__.py, - */debug.py -builtins = cookiecutter + doc/source/conf.py max-line-length = 115 -# Ignore some style 'errors' produced while formatting by 'black' (see link below) +# Ignore some style 'errors' produced while formatting by 'black' # https://black.readthedocs.io/en/stable/guides/using_black_with_other_tools.html#labels-why-pycodestyle-warnings extend-ignore = E203 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/.pre-commit-config.yaml b/.pre-commit-config.yaml index 26859828..3070e199 100644 --- a/.pre-commit-config.yaml +++ b/.pre-commit-config.yaml @@ -1,28 +1,29 @@ default_language_version: - python: python3 + python: python3 ci: - autofix_commit_msg: | - [pre-commit.ci] auto fixes from pre-commit hooks - autofix_prs: true - autoupdate_branch: 'pre-commit-autoupdate' - autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' - autoupdate_schedule: monthly - skip: [no-commit-to-branch] - submodules: false + autofix_commit_msg: | + [pre-commit.ci] auto fixes from pre-commit hooks + autofix_prs: true + autoupdate_branch: 'pre-commit-autoupdate' + autoupdate_commit_msg: '[pre-commit.ci] pre-commit autoupdate' + autoupdate_schedule: monthly + skip: [no-commit-to-branch] + submodules: false repos: - repo: https://github.com/pre-commit/pre-commit-hooks rev: v4.6.0 hooks: - id: check-yaml - exclude: 'environment.yml' - id: end-of-file-fixer - id: trailing-whitespace - exclude: '\.(rst|txt)$' + - id: check-case-conflict + - id: check-merge-conflict + - id: check-toml + - id: check-added-large-files - repo: https://github.com/psf/black rev: 24.4.2 hooks: - id: black - exclude: '.*\.py' - repo: https://github.com/pycqa/flake8 rev: 7.0.0 hooks: diff --git a/LICENSE_DANSE.txt b/LICENSE_DANSE.txt deleted file mode 100644 index c92ca2d5..00000000 --- a/LICENSE_DANSE.txt +++ /dev/null @@ -1,34 +0,0 @@ -This program is part of the DiffPy and DANSE open-source projects at Columbia -University and is available subject to the conditions and terms laid out below. - -Copyright (c) 2008-2011, The Trustees of Columbia University in -the City of New York. All rights reserved. - -For more information please visit the diffpy web-page at - http://www.diffpy.org -or email Prof. Simon Billinge at sb2896@columbia.edu. - -Redistribution and use in source and binary forms, with or without -modification, are permitted provided that the following conditions are met: - - * Redistributions of source code must retain the above copyright notice, this - list of conditions and the following disclaimer. - - * 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. - - * Neither the names of COLUMBIA UNIVERSITY, MICHIGAN STATE UNIVERSITY nor the - names of their 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 OWNER 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/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/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 diff --git a/tests/test_recipeorganizer.py b/tests/test_recipeorganizer.py index a65adf7c..70537c47 100644 --- a/tests/test_recipeorganizer.py +++ b/tests/test_recipeorganizer.py @@ -23,11 +23,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 # ---------------------------------------------------------------------------- diff --git a/tests/test_sgconstraints.py b/tests/test_sgconstraints.py index ea323a0f..4b985a21 100644 --- a/tests/test_sgconstraints.py +++ b/tests/test_sgconstraints.py @@ -18,13 +18,7 @@ import unittest import numpy -from utils import ( - _msg_nopyobjcryst, - _msg_nostructure, - datafile, - has_pyobjcryst, - has_structure, -) +from utils import _msg_nopyobjcryst, _msg_nostructure, datafile, has_pyobjcryst, has_structure # ---------------------------------------------------------------------------- diff --git a/tests/test_version.py b/tests/test_version.py new file mode 100644 index 00000000..23983a0a --- /dev/null +++ b/tests/test_version.py @@ -0,0 +1,10 @@ +"""Unit tests for __version__.py +""" + +import diffpy.srfit + + +def test_package_version(): + """Ensure the package version is defined and not set to the initial placeholder.""" + assert hasattr(diffpy.srfit, "__version__") + assert diffpy.srfit.__version__ != "0.0.0" From 99265fed7e271e8dc587c98c450f3494ca361b83 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:37:59 -0400 Subject: [PATCH 05/13] Add requirements --- requirements/build.txt | 0 requirements/docs.txt | 4 ++++ requirements/run.txt | 1 + 3 files changed, 5 insertions(+) create mode 100644 requirements/build.txt create mode 100644 requirements/docs.txt 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/run.txt b/requirements/run.txt index 59149ac8..1a106746 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,3 +1,4 @@ scipy numpy matplotlib +diffpy.structure \ No newline at end of file From 2183645dfa0263d71f30b523f5ffb19cffa376e1 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:38:11 -0400 Subject: [PATCH 06/13] Auhors, changelog, code of conduct --- AUTHORS.rst | 13 +++++ CHANGELOG.rst | 34 +++++++++++ CODE_OF_CONDUCT.rst | 133 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 180 insertions(+) create mode 100644 AUTHORS.rst create mode 100644 CHANGELOG.rst create mode 100644 CODE_OF_CONDUCT.rst diff --git a/AUTHORS.rst b/AUTHORS.rst new file mode 100644 index 00000000..7b2a5956 --- /dev/null +++ b/AUTHORS.rst @@ -0,0 +1,13 @@ +Authors +======= + +Chris Farrow +Pavol Juhas +Simon J.L. Billinge +Billinge Group and community contributors. + +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..f9c8f1cd --- /dev/null +++ b/CHANGELOG.rst @@ -0,0 +1,34 @@ +============= +Release Notes +============= + +3.0.0 +==== + +**Added** + +* Support for Python 3.7, 3.6, 3.5 in addition to 2.7. + +**Changed** + +* Always use lower-case imports from `diffpy.structure`. +* Use numeric-value sort to order variables in `PrintFitHook`. + +**Deprecated** + +* Variable `__gitsha__` in the `version` module renamed to `__git_commit__`. + +**Removed** + +* Optional upper and lower-bound arguments in `Parameter.setValue`. + The bounds can be set with `Parameter.boundRange` instead. +* Unused classes `ListOperator`, `SetOperator`. + +**Fixed** + +* Metadata retrieval from `PDFContribution` hierarchy. +* Refresh `PDFGenerator` when its `rgrid` is changed in-place. +* Zero division in the `nppdfsas.py` example. +* Crash in `ellipsoidsas.py` example because of bug in `Parameter.setValue`. +* Pickling of `ProfileGenerator` objects and of bound class methods. +* Invalid escape sequences in string values. 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 `_ From 0c8e78bcaacfbb0710442d2b8df5e25a5e1ff7f9 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:38:31 -0400 Subject: [PATCH 07/13] Delete older files --- .coveragerc | 22 -------- .gitarchive.cfg | 5 -- .gitattributes | 7 --- .idea/.gitignore | 8 --- .travis.yml | 123 ---------------------------------------- AUTHORS.txt | 9 --- CHANGELOG.md | 33 ----------- MANIFEST.in | 24 ++++---- README.rst | 137 ++++++++++++++++++++++++++++++--------------- devutils/makesdist | 60 -------------------- pyproject.toml | 17 ++++++ setup.txt | 130 ------------------------------------------ 12 files changed, 119 insertions(+), 456 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .gitarchive.cfg delete mode 100644 .gitattributes delete mode 100644 .idea/.gitignore delete mode 100644 .travis.yml delete mode 100644 AUTHORS.txt delete mode 100644 CHANGELOG.md delete mode 100755 devutils/makesdist delete mode 100755 setup.txt diff --git a/.coveragerc b/.coveragerc deleted file mode 100644 index d0a0d16d..00000000 --- a/.coveragerc +++ /dev/null @@ -1,22 +0,0 @@ -# Configuration of the coverage.py tool for reporting test coverage. - -[report] -# RE patterns for lines to be excluded from consideration. -exclude_lines = - ## Have to re-enable the standard pragma - pragma: no cover - ## Don't complain if tests don't hit defensive assertion code: - raise AssertionError - raise NotImplementedError - ^[ ]*assert False - - ## Don't complain if non-runnable code isn't run: - ^[ ]*@unittest.skip\b - ^[ ]{4}unittest.main() - if __name__ == .__main__.: - - -[run] -omit = - ## exclude debug.py from codecov report - */tests/debug.py diff --git a/.gitarchive.cfg b/.gitarchive.cfg deleted file mode 100644 index 95e1448c..00000000 --- a/.gitarchive.cfg +++ /dev/null @@ -1,5 +0,0 @@ -[DEFAULT] -commit = $Format:%H$ -date = $Format:%ci$ -timestamp = $Format:%ct$ -refnames = $Format:%D$ diff --git a/.gitattributes b/.gitattributes deleted file mode 100644 index 9d58a8cd..00000000 --- a/.gitattributes +++ /dev/null @@ -1,7 +0,0 @@ -/.gitattributes export-ignore -/.gitignore export-ignore -/.travis.yml export-ignore -/conda-recipe/ export-ignore -/devutils export-ignore -.gitarchive.cfg export-subst -*.bat text eol=crlf diff --git a/.idea/.gitignore b/.idea/.gitignore deleted file mode 100644 index 13566b81..00000000 --- a/.idea/.gitignore +++ /dev/null @@ -1,8 +0,0 @@ -# Default ignored files -/shelf/ -/workspace.xml -# Editor-based HTTP Client requests -/httpRequests/ -# Datasource local storage ignored files -/dataSources/ -/dataSources.local.xml diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index a3469af5..00000000 --- a/.travis.yml +++ /dev/null @@ -1,123 +0,0 @@ -dist: xenial -language: generic - -os: - - linux - - osx - -env: - - MYUSEMC=true MYPYTHON_VERSION=2.7 - - MYUSEMC=true MYPYTHON_VERSION=3.5 - - MYUSEMC=true MYPYTHON_VERSION=3.6 - - MYUSEMC=true MYPYTHON_VERSION=3.7 - - MYUSEMC=false - -git: - depth: 999999 - -branches: - except: - - /^v[0-9]/ - - -before_install: - - MYNAME=diffpy.srfit - - MYCOMMIT="$(git rev-parse HEAD)" - - umask 022 - - git fetch origin --tags - - MYPYTHON=python; MYPIP=pip - - NOSYS=true; NOAPT=true; NOBREW=true; NOMC=true - - if ${MYUSEMC}; then - NOMC=false; - elif [[ ${TRAVIS_OS_NAME} == linux ]]; then - NOAPT=false; NOSYS=false; - MYPIPFLAGS="--user"; - elif [[ ${TRAVIS_OS_NAME} == osx ]]; then - NOBREW=false; NOSYS=false; - MYPYTHON=python3; - MYPIP=pip3; - MYPIPFLAGS="--user"; - fi - - MYMCREPO=https://repo.anaconda.com/miniconda - - case ${TRAVIS_OS_NAME} in - linux) - MYMCBUNDLE=Miniconda3-latest-Linux-x86_64.sh ;; - osx) - MYMCBUNDLE=Miniconda3-latest-MacOSX-x86_64.sh ;; - *) - echo "Unsupported operating system." >&2; - exit 2 ;; - esac - - MYRUNDIR=${PWD}/build/rundir - - - mkdir -p ~/pkgs - - mkdir -p ${MYRUNDIR} - - cp .coveragerc ${MYRUNDIR}/ - - - $NOMC || pushd ~/pkgs - - $NOMC || wget --timestamping ${MYMCREPO}/${MYMCBUNDLE} - - $NOMC || test -x ~/mc/bin/conda || bash ${MYMCBUNDLE} -b -f -p ~/mc - - $NOMC || popd - - $NOMC || source ~/mc/bin/activate base - - $NOMC || conda update --yes conda - - $NOMC || conda install --yes conda-build conda-verify jinja2 - - $NOMC || conda create --name=testenv --yes python=${MYPYTHON_VERSION} coverage - - $NOMC || conda config --add channels diffpy - - - $NOAPT || test "${TRAVIS_OS_NAME}" = "linux" || exit $? - - $NOAPT || PATH="$(echo "$PATH" | sed 's,:/opt/pyenv/[^:]*,,g')" - - $NOAPT || test "$(which python)" = "/usr/bin/python" || ( - which python; exit 1) - - $NOAPT || sudo apt-get update -qq - - $NOAPT || sudo apt-get install -y - python-dev python-setuptools python-numpy - build-essential - - - $NOBREW || test "${TRAVIS_OS_NAME}" = "osx" || exit $? - - $NOBREW || brew update - - $NOBREW || brew upgrade python - - $NOBREW || brew install gcc || brew link --overwrite gcc - - - $NOSYS || devutils/makesdist - - $NOSYS || MYTARBUNDLE="$(ls -t "${PWD}"/dist/*.tar.gz | head -1)" - - -install: - - $NOMC || conda build --python=${MYPYTHON_VERSION} conda-recipe - - $NOMC || conda render --python=${MYPYTHON_VERSION} --output conda-recipe | - sed 's,.*/,,; s/[.]tar[.]bz2$//; s/-/=/g' > /tmp/mypackage.txt - - $NOMC || source activate testenv - - $NOMC || conda install --yes --use-local --file=/tmp/mypackage.txt - - $NOMC || conda install --yes - diffpy.structure pyobjcryst "diffpy.srreal>=1.3.0" - # TODO - always install srfit-sasview when ready for Python 3. - - if $MYUSEMC && [[ "$MYPYTHON_VERSION" == 2.7 ]]; then - conda install --yes srfit-sasview; - fi - - - $NOSYS || $MYPIP install $MYPIPFLAGS coverage - - $NOSYS || $MYPIP install $MYPIPFLAGS pycifrw - - $NOSYS || $MYPIP install $MYPIPFLAGS diffpy.structure - - $NOSYS || $MYPIP install $MYPIPFLAGS "${MYTARBUNDLE}" - - - cd ${MYRUNDIR} - - MYGIT_REV=$($MYPYTHON -c "import ${MYNAME}.version as v; print(v.__git_commit__)") - - if [[ "${MYCOMMIT}" != "${MYGIT_REV}" ]]; then - echo "Version mismatch ${MYCOMMIT} vs ${MYGIT_REV}."; - exit 1; - fi - - -before_script: - - $NOBREW || USER_BASE="$(python3 -c 'import site; print(site.USER_BASE)')" - - $NOBREW || PATH="${USER_BASE}/bin:${PATH}" - - -script: - - coverage run --source ${MYNAME} -m ${MYNAME}.tests.run - - -after_success: - # do not post coverage reports when testing with system Python. - - $NOMC || $MYPIP install $MYPIPFLAGS codecov - - $NOMC || codecov diff --git a/AUTHORS.txt b/AUTHORS.txt deleted file mode 100644 index 2e7b1714..00000000 --- a/AUTHORS.txt +++ /dev/null @@ -1,9 +0,0 @@ -Authors: - -Chris Farrow -Pavol Juhas -Simon J.L. Billinge - -Contributors: - -https://github.com/diffpy/diffpy.srfit/graphs/contributors diff --git a/CHANGELOG.md b/CHANGELOG.md deleted file mode 100644 index 7b90ae3f..00000000 --- a/CHANGELOG.md +++ /dev/null @@ -1,33 +0,0 @@ -# Release notes - -## Version 3.0.0 – 2019-03-14 - -Differences from version 1.3. - -### Added - -- Support for Python 3.7, 3.6, 3.5 in addition to 2.7. - -### Changed - -- Always use lower-case imports from `diffpy.structure`. -- Use numeric-value sort to order variables in `PrintFitHook`. - -### Deprecated - -- Variable `__gitsha__` in the `version` module renamed to `__git_commit__`. - -### Removed - -- Optional upper and lower-bound arguments in `Parameter.setValue`. - The bounds can be set with `Parameter.boundRange` instead. -- Unused classes `ListOperator`, `SetOperator`. - -### Fixed - -- Metadata retrieval from `PDFContribution` hierarchy. -- Refresh `PDFGenerator` when its `rgrid` is changed in-place. -- Zero division in the `nppdfsas.py` example. -- Crash in `ellipsoidsas.py` example because of bug in `Parameter.setValue`. -- Pickling of `ProfileGenerator` objects and of bound class methods. -- Invalid escape sequences in string values. diff --git a/MANIFEST.in b/MANIFEST.in index 3894e104..f1a78eec 100644 --- a/MANIFEST.in +++ b/MANIFEST.in @@ -1,16 +1,12 @@ -recursive-include src * -include AUTHORS.txt LICENSE*.txt README.rst -recursive-exclude src *.pyc -global-exclude .gitattributes .gitignore .gitarchive.cfg -global-exclude .DS_Store +graft src +graft tests +graft requirements -# Avoid user content in setup.cfg to make distribution reproducible. -exclude setup.cfg +include AUTHORS.rst LICENSE*.rst README.rst -# Exclude git-tracked files spuriously added by setuptools_scm -exclude .codecov.yml -exclude .coveragerc -exclude .travis* -prune conda-recipe -prune devutils -prune doc +# Exclude all bytecode files and __pycache__ directories +global-exclude *.py[cod] # Exclude all .pyc, .pyo, and .pyd files. +global-exclude .DS_Store # Exclude Mac filesystem artifacts. +global-exclude __pycache__ # Exclude Python cache directories. +global-exclude .git* # Exclude git files and directories. +global-exclude .idea # Exclude PyCharm project settings. diff --git a/README.rst b/README.rst index 59fefa83..c1060095 100644 --- a/README.rst +++ b/README.rst @@ -1,12 +1,41 @@ -.. image:: https://travis-ci.org/diffpy/diffpy.srfit.svg?branch=master - :target: https://travis-ci.org/diffpy/diffpy.srfit +|Icon| |title|_ +=============== -.. image:: https://codecov.io/gh/diffpy/diffpy.srfit/branch/master/graph/badge.svg - :target: https://codecov.io/gh/diffpy/diffpy.srfit +.. |title| replace:: diffpy.srfit +.. _title: https://diffpy.github.io/diffpy.srfit +.. |Icon| image:: https://avatars.githubusercontent.com/diffpy + :target: https://diffpy.github.io/diffpy.srfit + :height: 100px -diffpy.srfit -======================================================================== +|PyPi| |Forge| |PythonVersion| |PR| + +|CI| |Codecov| |Black| |Tracking| + +.. |Black| image:: https://img.shields.io/badge/code_style-black-black + :target: https://github.com/psf/black + +.. |CI| image:: https://github.com/diffpy/diffpy.srfit/actions/workflows/matrix-and-codecov-on-merge-to-main.yml/badge.svg + :target: https://github.com/diffpy/diffpy.srfit/actions/workflows/matrix-and-codecov-on-merge-to-main.yml + +.. |Codecov| image:: https://codecov.io/gh/diffpy/diffpy.srfit/branch/main/graph/badge.svg + :target: https://codecov.io/gh/diffpy/diffpy.srfit + +.. |Forge| image:: https://img.shields.io/conda/vn/conda-forge/diffpy.srfit + :target: https://anaconda.org/conda-forge/diffpy.srfit + +.. |PR| image:: https://img.shields.io/badge/PR-Welcome-29ab47ff + +.. |PyPi| image:: https://img.shields.io/pypi/v/diffpy.srfit + :target: https://pypi.org/project/diffpy.srfit/ + +.. |PythonVersion| image:: https://img.shields.io/pypi/pyversions/diffpy.srfit + :target: https://pypi.org/project/diffpy.srfit/ + +.. |Tracking| image:: https://img.shields.io/badge/issue_tracking-github-blue + :target: https://github.com/diffpy/diffpy.srfit/issues + +Python package for structure refinement from diffraction data. Configurable code for solving atomic structures. @@ -35,7 +64,14 @@ co-refinements with other techniques. For more information about the diffpy.srfit library, see the users manual at http://diffpy.github.io/diffpy.srfit. -REQUIREMENTS +Citation +-------- + +If you use diffpy.srfit in a scientific publication, we would like you to cite this package as + + diffpy.srfit Package, https://github.com/diffpy/diffpy.srfit + +Requirements ------------------------------------------------------------------------ The diffpy.srfit package requires Python 3.5 or later or 2.7 and @@ -79,68 +115,79 @@ Linux some of the required software can be installed using :: For other required packages see their respective web pages for installation instructions. +Installation +------------ -INSTALLATION ------------------------------------------------------------------------- +The preferred method is to use `Miniconda Python +`_ +and install from the "conda-forge" channel of Conda packages. -The preferred method is to use Anaconda Python and install from the -"diffpy" channel of Anaconda packages :: +To add "conda-forge" to the conda channels, run the following in a terminal. :: - conda config --add channels diffpy - conda install diffpy.srfit + conda config --add channels conda-forge -diffpy.srfit is also included in the "diffpy-cmi" collection -of packages for structure analysis :: +We want to install our packages in a suitable conda environment. +The following creates and activates a new environment named ``diffpy.srfit_env`` :: - conda install diffpy-cmi + conda create -n diffpy.srfit_env python=3 + conda activate diffpy.srfit_env -Another option is to use ``easy_install`` to download and install the -latest release from `Python Package Index `_ :: +Then, to fully install ``diffpy.srfit`` in our active environment, run :: - easy_install diffpy.srfit + conda install diffpy.srfit -If you prefer to install from sources, make sure all required software -packages are in place and then run :: +Another option is to use ``pip`` to download and install the latest release from +`Python Package Index `_. +To install using ``pip`` into your ``diffpy.srfit_env`` environment, type :: - python setup.py install + pip install diffpy.srfit -You may need to use ``sudo`` with system Python so the process is -allowed to put files to the system directories. If administrator (root) -access is not available, consult the output from -``python setup.py install --help`` for options to install to a -user-writable locations. The installation integrity can be verified by -changing to the HOME directory and running :: +If you prefer to install from sources, after installing the dependencies, obtain the source archive from +`GitHub `_. Once installed, ``cd`` into your ``diffpy.srfit`` directory +and run the following :: - python -m diffpy.srfit.tests.run + pip install . +Support and Contribute +---------------------- -DEVELOPMENT ------------------------------------------------------------------------- +`Diffpy user group `_ is the discussion forum for general questions and discussions about the use of diffpy.srfit. Please join the diffpy.srfit users community by joining the Google group. The diffpy.srfit project welcomes your expertise and enthusiasm! + +If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. diffpy.srfit is an open-source software developed as a part of the DiffPy-CMI -complex modeling initiative at the Brookhaven National Laboratory. The -diffpy.srfit sources are hosted at -https://github.com/diffpy/diffpy.srfit. +complex modeling initiative at the Brookhaven National Laboratory. -Feel free to fork the project and contribute. To install diffpy.srfit +Feel free to fork the project and contribute. To install diffpy.srfit in a development mode, with its sources being directly used by Python -rather than copied to a package directory, use :: +rather than copied to a package directory, use the following in the root +directory :: - python setup.py develop --user + 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. -ACKNOWLEDGEMENT ------------------------------------------------------------------------- +1. Install pre-commit in your working environment by running ``conda install pre-commit``. -The source code in *observable.py* was derived from the 1.0 version -of the Caltech "Pyre" project. +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. + +Improvements and fixes are always appreciated. +Before contribuing, please read our `Code of Conduct `_. -CONTACTS +Acknowledgement ------------------------------------------------------------------------ -For more information on diffpy.srfit please visit the project web-page +The source code in *observable.py* was derived from the 1.0 version +of the Caltech "Pyre" project. -http://www.diffpy.org +Contact +------- -or email Prof. Simon Billinge at sb2896@columbia.edu. +For more information on diffpy.srfit please visit the project `web-page `_ or email Prof. Simon Billinge at sb2896@columbia.edu. diff --git a/devutils/makesdist b/devutils/makesdist deleted file mode 100755 index dccfaa99..00000000 --- a/devutils/makesdist +++ /dev/null @@ -1,60 +0,0 @@ -#!/usr/bin/env python - -"""Create source distribution tar.gz archive, where each file belongs -to a root user and modification time is set to the git commit time. -""" - -import glob -import gzip -import os -import subprocess -import sys -import tarfile - -from setup import FALLBACK_VERSION, versiondata - -BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) -sys.path.insert(0, BASEDIR) - -timestamp = versiondata.getint("DEFAULT", "timestamp") - -vfb = versiondata.get("DEFAULT", "version").split(".post")[0] + ".post0" -emsg = "Invalid FALLBACK_VERSION. Expected %r got %r." -assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION) - - -def inform(s): - sys.stdout.write(s) - sys.stdout.flush() - return - - -inform('Run "setup.py sdist --formats=tar" ') -cmd_sdist = [sys.executable] + "setup.py sdist --formats=tar".split() -ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, "w")) -if ec: - sys.exit(ec) -inform("[done]\n") - -tarname = max(glob.glob(BASEDIR + "/dist/*.tar"), key=os.path.getmtime) - -tfin = tarfile.open(tarname) -fpout = gzip.GzipFile(tarname + ".gz", "w", mtime=0) -tfout = tarfile.open(fileobj=fpout, mode="w") - - -def fixtarinfo(tinfo): - tinfo.uid = tinfo.gid = 0 - tinfo.uname = tinfo.gname = "root" - tinfo.mtime = timestamp - tinfo.mode &= ~0o022 - return tinfo - - -inform("Filter %s --> %s.gz " % (2 * (os.path.basename(tarname),))) -for ti in tfin: - tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti)) - -tfin.close() -os.remove(tarname) -inform("[done]\n") diff --git a/pyproject.toml b/pyproject.toml index 22663b7f..fe07f87d 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -5,19 +5,36 @@ build-backend = "setuptools.build_meta" [project] name = "diffpy.srfit" dynamic=['version', 'dependencies'] +authors = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +maintainers = [ + { name="Simon J.L. Billinge group", email="simon.billinge@gmail.com" }, +] +description = "Python package for structure refinement from diffraction data." +keywords = ['optimization', 'constraints', 'restraints', 'structure refinement', 'complex modeling'] +readme = "README.rst" +requires-python = ">=3.10" classifiers = [ 'Development Status :: 5 - Production/Stable', 'Environment :: Console', 'Intended Audience :: Developers', 'Intended Audience :: Science/Research', + 'License :: Free To Use But Restricted', 'Operating System :: MacOS :: MacOS X', 'Operating System :: Microsoft :: Windows', 'Operating System :: POSIX', 'Operating System :: Unix', + 'Programming Language :: Python :: 3.10', + '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.srfit/" +Issues = "https://github.com/diffpy/diffpy.srfit/issues/" [tool.setuptools-git-versioning] enabled = true diff --git a/setup.txt b/setup.txt deleted file mode 100755 index 9318c322..00000000 --- a/setup.txt +++ /dev/null @@ -1,130 +0,0 @@ -#!/usr/bin/env python - -# Installation script for diffpy.srfit - -"""diffpy.srfit - framework for setting up complex modeling refinements. - -Packages: diffpy.srfit -""" - -import os -import re -import sys - -from setuptools import find_packages, setup - -# Use this version when git data are not available, like in git zip archive. -# Update when tagging a new release. -FALLBACK_VERSION = "3.0.0.post0" - -# determine if we run with Python 3. -PY3 = sys.version_info[0] == 3 - -# versioncfgfile holds version data for git commit hash and date. -# It must reside in the same directory as version.py. -MYDIR = os.path.dirname(os.path.abspath(__file__)) -versioncfgfile = os.path.join(MYDIR, "src/diffpy/srfit/version.cfg") -gitarchivecfgfile = os.path.join(MYDIR, ".gitarchive.cfg") - - -def gitinfo(): - from subprocess import PIPE, Popen - - kw = dict(stdout=PIPE, cwd=MYDIR, universal_newlines=True) - proc = Popen(["git", "describe", "--match=v[[:digit:]]*"], **kw) - desc = proc.stdout.read() - proc = Popen(["git", "log", "-1", "--format=%H %ct %ci"], **kw) - glog = proc.stdout.read() - rv = {} - rv["version"] = ".post".join(desc.strip().split("-")[:2]).lstrip("v") - rv["commit"], rv["timestamp"], rv["date"] = glog.strip().split(None, 2) - return rv - - -def getversioncfg(): - if PY3: - from configparser import RawConfigParser - else: - from ConfigParser import RawConfigParser - vd0 = dict(version=FALLBACK_VERSION, commit="", date="", timestamp=0) - # first fetch data from gitarchivecfgfile, ignore if it is unexpanded - g = vd0.copy() - cp0 = RawConfigParser(vd0) - cp0.read(gitarchivecfgfile) - if len(cp0.get("DEFAULT", "commit")) > 20: - g = cp0.defaults() - mx = re.search(r"\btag: v(\d[^,]*)", g.pop("refnames")) - if mx: - g["version"] = mx.group(1) - # then try to obtain version data from git. - gitdir = os.path.join(MYDIR, ".git") - if os.path.exists(gitdir) or "GIT_DIR" in os.environ: - try: - g = gitinfo() - except OSError: - pass - # finally, check and update the active version file - cp = RawConfigParser() - cp.read(versioncfgfile) - d = cp.defaults() - rewrite = not d or (g["commit"] and (g["version"] != d.get("version") or g["commit"] != d.get("commit"))) - if rewrite: - cp.set("DEFAULT", "version", g["version"]) - cp.set("DEFAULT", "commit", g["commit"]) - cp.set("DEFAULT", "date", g["date"]) - cp.set("DEFAULT", "timestamp", g["timestamp"]) - with open(versioncfgfile, "w") as fp: - cp.write(fp) - return cp - - -versiondata = getversioncfg() - -with open(os.path.join(MYDIR, "README.rst")) as fp: - long_description = fp.read() - -# define distribution -setup_args = dict( - name="diffpy.srfit", - version=versiondata.get("DEFAULT", "version"), - packages=find_packages(os.path.join(MYDIR, "src")), - package_dir={"": "src"}, - test_suite="diffpy.srfit.tests", - include_package_data=True, - install_requires=["six"], - zip_safe=False, - author="Simon J.L. Billinge", - author_email="sb2896@columbia.edu", - maintainer="Pavol Juhas", - maintainer_email="pavol.juhas@gmail.com", - description="SrFit - Structure refinement from diffraction data", - long_description=long_description, - long_description_content_type="text/x-rst", - license="BSD-style license", - url="https://github.com/diffpy/diffpy.srfit", - keywords="optimization constraints restraints structure refinement complex modeling", - classifiers=[ - # List of possible values at - # http://pypi.python.org/pypi?:action=list_classifiers - "Development Status :: 5 - Production/Stable", - "Environment :: Console", - "Intended Audience :: Developers", - "Intended Audience :: Education", - "Intended Audience :: Science/Research", - "License :: OSI Approved :: BSD License", - "Operating System :: MacOS", - "Operating System :: POSIX", - "Programming Language :: Python :: 2.7", - "Programming Language :: Python :: 3.5", - "Programming Language :: Python :: 3.6", - "Programming Language :: Python :: 3.7", - "Topic :: Scientific/Engineering :: Chemistry", - "Topic :: Scientific/Engineering :: Physics", - "Topic :: Software Development :: Libraries", - ], -) - -if __name__ == "__main__": - setup(**setup_args) - -# End of file From f64b601540277d5f46453c5b1793c1b35b8d3315 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:39:20 -0400 Subject: [PATCH 08/13] Add coveragerc --- .coveragerc | 13 +++++++++++++ 1 file changed, 13 insertions(+) create mode 100644 .coveragerc diff --git a/.coveragerc b/.coveragerc new file mode 100644 index 00000000..fe3daa8e --- /dev/null +++ b/.coveragerc @@ -0,0 +1,13 @@ +[run] +source = + diffpy.srfit +[report] +omit = + */python?.?/* + */site-packages/nose/* + # ignore _version.py and versioneer.py + .*version.* + *_version.py + +exclude_lines = + if __name__ == '__main__': From a9c853c85f43c2fdc9c4a82b147aa6e77c60c966 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:42:00 -0400 Subject: [PATCH 09/13] Add limited license --- doc/source/license.rst | 165 +++++++++++++++++++++++++++++++++-------- 1 file changed, 135 insertions(+), 30 deletions(-) diff --git a/doc/source/license.rst b/doc/source/license.rst index 9ae52a98..72aaee94 100644 --- a/doc/source/license.rst +++ b/doc/source/license.rst @@ -7,33 +7,138 @@ 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. + +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. + + +END OF LICENSE From 7224746927982759eef2d105e34db730ae52f5b3 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:43:46 -0400 Subject: [PATCH 10/13] Add diffpy.structure under run-ext --- news/TEMPLATE copy.rst | 23 +++++++++++++++++++++++ requirements/run-ext.txt | 1 + requirements/run.txt | 1 - 3 files changed, 24 insertions(+), 1 deletion(-) create mode 100644 news/TEMPLATE copy.rst create mode 100644 requirements/run-ext.txt diff --git a/news/TEMPLATE copy.rst b/news/TEMPLATE copy.rst new file mode 100644 index 00000000..7a814233 --- /dev/null +++ b/news/TEMPLATE copy.rst @@ -0,0 +1,23 @@ +**Added:** + +* + +**Changed:** + +* + +**Deprecated:** + +* + +**Removed:** + +* + +**Fixed:** + +* cookiecut to group's Python package standard + +**Security:** + +* diff --git a/requirements/run-ext.txt b/requirements/run-ext.txt new file mode 100644 index 00000000..9cc306b0 --- /dev/null +++ b/requirements/run-ext.txt @@ -0,0 +1 @@ +diffpy.structure diff --git a/requirements/run.txt b/requirements/run.txt index 1a106746..59149ac8 100644 --- a/requirements/run.txt +++ b/requirements/run.txt @@ -1,4 +1,3 @@ scipy numpy matplotlib -diffpy.structure \ No newline at end of file From 89ddff43b049c1408ba8692c6c29217965928560 Mon Sep 17 00:00:00 2001 From: "pre-commit-ci[bot]" <66853113+pre-commit-ci[bot]@users.noreply.github.com> Date: Mon, 30 Sep 2024 19:44:49 +0000 Subject: [PATCH 11/13] [pre-commit.ci] auto fixes from pre-commit hooks --- doc/source/api/diffpy.srfit.equation.literals.rst | 1 - doc/source/api/diffpy.srfit.equation.rst | 1 - doc/source/api/diffpy.srfit.equation.visitors.rst | 1 - doc/source/api/diffpy.srfit.fitbase.rst | 1 - doc/source/api/diffpy.srfit.interface.rst | 1 - doc/source/api/diffpy.srfit.pdf.rst | 1 - doc/source/api/diffpy.srfit.rst | 1 - doc/source/api/diffpy.srfit.sas.rst | 1 - doc/source/api/diffpy.srfit.structure.rst | 1 - doc/source/api/diffpy.srfit.util.rst | 1 - 10 files changed, 10 deletions(-) diff --git a/doc/source/api/diffpy.srfit.equation.literals.rst b/doc/source/api/diffpy.srfit.equation.literals.rst index 6875b5ef..20679c3e 100644 --- a/doc/source/api/diffpy.srfit.equation.literals.rst +++ b/doc/source/api/diffpy.srfit.equation.literals.rst @@ -42,4 +42,3 @@ diffpy.srfit.equation.literals.operators module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.equation.rst b/doc/source/api/diffpy.srfit.equation.rst index f7a47192..ef74cf23 100644 --- a/doc/source/api/diffpy.srfit.equation.rst +++ b/doc/source/api/diffpy.srfit.equation.rst @@ -35,4 +35,3 @@ diffpy.srfit.equation.equationmod module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.equation.visitors.rst b/doc/source/api/diffpy.srfit.equation.visitors.rst index 54e10bc6..88c35374 100644 --- a/doc/source/api/diffpy.srfit.equation.visitors.rst +++ b/doc/source/api/diffpy.srfit.equation.visitors.rst @@ -50,4 +50,3 @@ diffpy.srfit.equation.visitors.printer module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.fitbase.rst b/doc/source/api/diffpy.srfit.fitbase.rst index 5c092c9f..19bc255e 100644 --- a/doc/source/api/diffpy.srfit.fitbase.rst +++ b/doc/source/api/diffpy.srfit.fitbase.rst @@ -138,4 +138,3 @@ diffpy.srfit.fitbase.profileparser module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.interface.rst b/doc/source/api/diffpy.srfit.interface.rst index 40b829d7..92497fea 100644 --- a/doc/source/api/diffpy.srfit.interface.rst +++ b/doc/source/api/diffpy.srfit.interface.rst @@ -18,4 +18,3 @@ diffpy.srfit.interface.interface module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.pdf.rst b/doc/source/api/diffpy.srfit.pdf.rst index 60f3e947..424c7f16 100644 --- a/doc/source/api/diffpy.srfit.pdf.rst +++ b/doc/source/api/diffpy.srfit.pdf.rst @@ -58,4 +58,3 @@ diffpy.srfit.pdf.pdfcontribution module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.rst b/doc/source/api/diffpy.srfit.rst index 9eef9e38..8f840d0c 100644 --- a/doc/source/api/diffpy.srfit.rst +++ b/doc/source/api/diffpy.srfit.rst @@ -32,4 +32,3 @@ diffpy.srfit.exceptions module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.sas.rst b/doc/source/api/diffpy.srfit.sas.rst index fbc67925..8ad88d91 100644 --- a/doc/source/api/diffpy.srfit.sas.rst +++ b/doc/source/api/diffpy.srfit.sas.rst @@ -58,4 +58,3 @@ diffpy.srfit.sas.sasgenerator module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.structure.rst b/doc/source/api/diffpy.srfit.structure.rst index 1fa5326d..59063abd 100644 --- a/doc/source/api/diffpy.srfit.structure.rst +++ b/doc/source/api/diffpy.srfit.structure.rst @@ -66,4 +66,3 @@ diffpy.srfit.structure.sgconstraints module :members: :undoc-members: :show-inheritance: - diff --git a/doc/source/api/diffpy.srfit.util.rst b/doc/source/api/diffpy.srfit.util.rst index b96e6945..2471e5ad 100644 --- a/doc/source/api/diffpy.srfit.util.rst +++ b/doc/source/api/diffpy.srfit.util.rst @@ -58,4 +58,3 @@ diffpy.srfit.util.weakrefcallable module :members: :undoc-members: :show-inheritance: - From 6fe1508c9798f0e70f1a25555ad1132d09110a7b Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 15:45:36 -0400 Subject: [PATCH 12/13] Change news name to cookie --- news/{TEMPLATE copy.rst => cookie.rst} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename news/{TEMPLATE copy.rst => cookie.rst} (100%) diff --git a/news/TEMPLATE copy.rst b/news/cookie.rst similarity index 100% rename from news/TEMPLATE copy.rst rename to news/cookie.rst From f0debb91cb90be88ed53188af270d34d30a33ec1 Mon Sep 17 00:00:00 2001 From: Sangjoon Bob Lee Date: Mon, 30 Sep 2024 21:06:10 -0400 Subject: [PATCH 13/13] Update citation and fix being developed at columbia --- README.rst | 13 ++++++++++--- 1 file changed, 10 insertions(+), 3 deletions(-) diff --git a/README.rst b/README.rst index c1060095..b4ae141f 100644 --- a/README.rst +++ b/README.rst @@ -67,9 +67,16 @@ http://diffpy.github.io/diffpy.srfit. Citation -------- -If you use diffpy.srfit in a scientific publication, we would like you to cite this package as +If you use this program for a scientific research that leads +to publication, we ask that you acknowledge use of the program +by citing the following paper in your publication: - diffpy.srfit Package, https://github.com/diffpy/diffpy.srfit + P. Juhás, C. L. Farrow, X. Yang, K. R. Knox and S. J. L. Billinge, + `Complex modeling: a strategy and software program for combining + multiple information sources to solve ill posed structure and + nanostructure inverse problems + `__, + *Acta Crystallogr. A* **71**, 562-568 (2015). Requirements ------------------------------------------------------------------------ @@ -156,7 +163,7 @@ Support and Contribute If you see a bug or want to request a feature, please `report it as an issue `_ and/or `submit a fix as a PR `_. You can also post it to the `Diffpy user group `_. diffpy.srfit is an open-source software developed as a part of the DiffPy-CMI -complex modeling initiative at the Brookhaven National Laboratory. +complex modeling initiative at Columbia University. Feel free to fork the project and contribute. To install diffpy.srfit in a development mode, with its sources being directly used by Python