From 6ee87b2df6110ea72da4bd14025191d365e2ff0b Mon Sep 17 00:00:00 2001 From: Pavol Juhas Date: Thu, 3 May 2018 16:38:22 -0400 Subject: [PATCH] Shut off the 'python3' branch --- .coveragerc | 22 -- .gitarchive.cfg | 5 - .gitattributes | 7 - .gitignore | 43 --- .travis.yml | 99 ------- AUTHORS.txt | 4 - LICENSE.txt | 137 --------- LICENSE_DANSE.txt | 41 --- MANIFEST.in | 15 - README.rst | 93 +----- conda-recipe/bld.bat | 7 - conda-recipe/build.sh | 8 - conda-recipe/meta.yaml | 53 ---- conda-recipe/run_test.py | 4 - devutils/makesdist | 54 ---- doc/manual/Makefile | 193 ------------ doc/manual/source/api/diffpy.rst | 17 -- .../source/api/diffpy.utils.parsers.rst | 30 -- doc/manual/source/api/diffpy.utils.rst | 30 -- doc/manual/source/api/diffpy.utils.wx.rst | 22 -- doc/manual/source/api/modules.rst | 7 - doc/manual/source/conf.py | 278 ------------------ doc/manual/source/index.rst | 58 ---- setup.py | 114 ------- src/diffpy/utils/__init__.py | 29 -- src/diffpy/utils/parsers/__init__.py | 25 -- src/diffpy/utils/parsers/loaddata.py | 250 ---------------- src/diffpy/utils/parsers/resample.py | 107 ------- src/diffpy/utils/tests/__init__.py | 79 ----- src/diffpy/utils/tests/debug.py | 33 --- src/diffpy/utils/tests/run.py | 27 -- .../utils/tests/testdata/loaddata01.txt | 5 - src/diffpy/utils/tests/testhelpers.py | 26 -- src/diffpy/utils/tests/testloaddata.py | 52 ---- src/diffpy/utils/version.py | 55 ---- src/diffpy/utils/wx/__init__.py | 21 -- src/diffpy/utils/wx/gridutils.py | 158 ---------- switch-to-master.rst | 1 + 38 files changed, 5 insertions(+), 2204 deletions(-) delete mode 100644 .coveragerc delete mode 100644 .gitarchive.cfg delete mode 100644 .gitattributes delete mode 100644 .gitignore delete mode 100644 .travis.yml delete mode 100644 AUTHORS.txt delete mode 100644 LICENSE.txt delete mode 100644 LICENSE_DANSE.txt delete mode 100644 MANIFEST.in delete mode 100644 conda-recipe/bld.bat delete mode 100644 conda-recipe/build.sh delete mode 100644 conda-recipe/meta.yaml delete mode 100644 conda-recipe/run_test.py delete mode 100755 devutils/makesdist delete mode 100644 doc/manual/Makefile delete mode 100644 doc/manual/source/api/diffpy.rst delete mode 100644 doc/manual/source/api/diffpy.utils.parsers.rst delete mode 100644 doc/manual/source/api/diffpy.utils.rst delete mode 100644 doc/manual/source/api/diffpy.utils.wx.rst delete mode 100644 doc/manual/source/api/modules.rst delete mode 100644 doc/manual/source/conf.py delete mode 100644 doc/manual/source/index.rst delete mode 100755 setup.py delete mode 100644 src/diffpy/utils/__init__.py delete mode 100644 src/diffpy/utils/parsers/__init__.py delete mode 100644 src/diffpy/utils/parsers/loaddata.py delete mode 100644 src/diffpy/utils/parsers/resample.py delete mode 100644 src/diffpy/utils/tests/__init__.py delete mode 100644 src/diffpy/utils/tests/debug.py delete mode 100644 src/diffpy/utils/tests/run.py delete mode 100644 src/diffpy/utils/tests/testdata/loaddata01.txt delete mode 100644 src/diffpy/utils/tests/testhelpers.py delete mode 100644 src/diffpy/utils/tests/testloaddata.py delete mode 100644 src/diffpy/utils/version.py delete mode 100644 src/diffpy/utils/wx/__init__.py delete mode 100644 src/diffpy/utils/wx/gridutils.py create mode 120000 switch-to-master.rst 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 2c3906b0..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 -/doc export-ignore -.gitarchive.cfg export-subst diff --git a/.gitignore b/.gitignore deleted file mode 100644 index 435c0626..00000000 --- a/.gitignore +++ /dev/null @@ -1,43 +0,0 @@ -*.py[cod] - -# C extensions -*.so - -# Packages -*.egg -*.egg-info -dist -build -eggs -parts -bin -var -sdist -temp -develop-eggs -.installed.cfg -lib -lib64 -tags -errors.err - -# Installer logs -pip-log.txt -MANIFEST - -# Unit test / coverage reports -.coverage -.tox -nosetests.xml - -# Translations -*.mo - -# Mr Developer -.mr.developer.cfg -.project -.pydevproject - -# version information -setup.cfg -/src/diffpy/*/version.cfg diff --git a/.travis.yml b/.travis.yml deleted file mode 100644 index c2bc87d6..00000000 --- a/.travis.yml +++ /dev/null @@ -1,99 +0,0 @@ -# Use container-based travis workers -sudo: false - -language: generic - -os: - - linux - - osx - -env: - - MYUSEMC=true MYPYTHON_VERSION=3.4 - - MYUSEMC=true MYPYTHON_VERSION=3.5 - - MYUSEMC=true MYPYTHON_VERSION=3.6 - - MYUSEMC=false - -matrix: - exclude: - - os: linux - env: MYUSEMC=false - -git: - depth: 999999 - -branches: - except: - - /^v[0-9]/ - -before_install: - - MYNAME=diffpy.utils - - MYCOMMIT="$(git rev-parse HEAD)" - - umask 022 - - git fetch origin --tags - - if ${MYUSEMC}; then - NOBREW=true; NOMC=false; - MYPIP=pip; - else - NOBREW=false; NOMC=true; - MYPIP=pip3; MYPIPFLAGS="--user"; - fi - - MYMCREPO=https://repo.continuum.io/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 jinja2 - - $NOMC || conda create --name=testenv --yes python=${MYPYTHON_VERSION} coverage - - - $NOBREW || test "${TRAVIS_OS_NAME}" = "osx" || exit $? - - $NOBREW || brew update - - $NOBREW || brew upgrade python - - $NOBREW || brew install gcc || brew link --overwrite gcc - - $NOBREW || brew install --without-python@2 numpy - - $NOBREW || devutils/makesdist - - $NOBREW || 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 - - - $NOBREW || $MYPIP install $MYPIPFLAGS coverage - - $NOBREW || $MYPIP install $MYPIPFLAGS "${MYTARBUNDLE}" - - - cd ${MYRUNDIR} - - MYGIT_REV=$(python3 -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: - - $MYPIP install $MYPIPFLAGS codecov - - codecov diff --git a/AUTHORS.txt b/AUTHORS.txt deleted file mode 100644 index 08950ab1..00000000 --- a/AUTHORS.txt +++ /dev/null @@ -1,4 +0,0 @@ -Pavol Juhas -Timur Davis -Christopher L. Farrow -Simon J.L. Billinge diff --git a/LICENSE.txt b/LICENSE.txt deleted file mode 100644 index 2a9200d2..00000000 --- a/LICENSE.txt +++ /dev/null @@ -1,137 +0,0 @@ -OPEN SOURCE LICENSE AGREEMENT -============================= - -Copyright (c) 2009-2011, University of Tennessee -Copyright (c) 1989, 1991 Free Software Foundation, Inc. -Copyright (c) 2006, The Regents of the University of California through - Lawrence Berkeley National Laboratory -Copyright (c) 2014, Australian Synchrotron Research Program Inc., ("ASRP") -Copyright (c) 2006-2007, Board of Trustees of Michigan State University -Copyright (c) 2008-2012, The Trustees of Columbia University in the City - of New York - -Copyright (c) 2014-2017, 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 diff --git a/LICENSE_DANSE.txt b/LICENSE_DANSE.txt deleted file mode 100644 index b7e1c702..00000000 --- a/LICENSE_DANSE.txt +++ /dev/null @@ -1,41 +0,0 @@ -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). - -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. diff --git a/MANIFEST.in b/MANIFEST.in deleted file mode 100644 index 1e928c83..00000000 --- a/MANIFEST.in +++ /dev/null @@ -1,15 +0,0 @@ -recursive-include src * -include AUTHORS.txt LICENSE*.txt README.rst -recursive-exclude src *.py[co] -global-exclude .gitattributes .gitignore .gitarchive.cfg -global-exclude .DS_Store - -# Avoid user content in setup.cfg to make distribution reproducible. -exclude setup.cfg - -# Exclude git-tracked files spuriously added by setuptools_scm -exclude .coveragerc -exclude .travis* -prune conda-recipe -prune devutils -prune doc diff --git a/README.rst b/README.rst index 3f3d075a..be1390fb 100644 --- a/README.rst +++ b/README.rst @@ -1,94 +1,9 @@ -.. image:: https://travis-ci.org/diffpy/diffpy.utils.svg?branch=python3 - :target: https://travis-ci.org/diffpy/diffpy.utils - -.. image:: http://codecov.io/github/diffpy/diffpy.utils/coverage.svg?branch=python3 - :target: http://codecov.io/github/diffpy/diffpy.utils?branch=python3 - - diffpy.utils ======================================================================== -General purpose shared utilities for the diffpy libraries. - -The diffpy.utils package provides functions for extracting array data from -variously formatted text files and wx GUI utilities used by the PDFgui -program. The package also includes an interpolation function based on the -Whittaker-Shannon formula that can be used to resample a PDF or other profile -function over a new grid. - -For more information about the diffpy.utils library, see the users manual at -http://diffpy.github.io/diffpy.utils. - - -REQUIREMENTS ------------------------------------------------------------------------- - -The diffpy.utils package requires Python 2.6 or 2.7 and the following software: - -* ``setuptools`` - tools for installing Python packages -* ``NumPy`` - library for scientific computing with Python - -The functions in diffpy.utils.wx module require - -* ``wxPython`` - GUI toolkit for the Python language - -We recommend to use `Anaconda Python `_ -as it allows to install the software dependencies together with -diffpy.utils. For other Python distributions it is necessary to install -the required software separately. As an example, on Ubuntu Linux the -required software can be installed with :: - - sudo apt-get install python-setuptools python-numpy - - -INSTALLATION ------------------------------------------------------------------------- - -The preferred method is to use Anaconda Python and install from the -"diffpy" channel of Anaconda packages :: - - conda config --add channels diffpy - conda install diffpy.utils - -Another option is to use ``easy_install`` to download and install the -latest release from `Python Package Index `_ :: - - easy_install diffpy.utils - -If you prefer to install from sources, obtain the source archive and -run :: - - python setup.py install - -You may need to use ``sudo`` with system Python as it attempts to -install to standard system directories. If sudo is not available, check -the usage info from ``python setup.py install --help`` for options to -install to user-writable locations. The installation integrity can be -verified by changing to the HOME directory and running :: - - python -m diffpy.utils.tests.run - - -DEVELOPMENT ------------------------------------------------------------------------- - -diffpy.utils is an open-source software developed as a part of the -DiffPy-CMI complex modeling initiative at the Brookhaven National -Laboratory. The diffpy.utils sources are hosted at -https://github.com/diffpy/diffpy.utils. - -Feel free to fork the project and contribute. To install diffpy.utils -in a development mode, with its sources being directly used by Python -rather than copied to a package directory, use :: - - python setup.py develop --user - - -CONTACTS ------------------------------------------------------------------------- - -For more information on diffpy.utils please visit the project web-page +2018-05-03 -http://www.diffpy.org/ +The ``python3`` branch was merged to ``master`` as of +https://github.com/diffpy/diffpy.utils/commit/1b969e7d9267f2558f13800650fb0401f6ec6da3 -or email Prof. Simon Billinge at sb2896@columbia.edu. +Please switch to the master branch. diff --git a/conda-recipe/bld.bat b/conda-recipe/bld.bat deleted file mode 100644 index 0a79fa23..00000000 --- a/conda-recipe/bld.bat +++ /dev/null @@ -1,7 +0,0 @@ -"%PYTHON%" setup.py install -if errorlevel 1 exit 1 - -:: Add more build steps here, if they are necessary. - -:: See http://docs.continuum.io/conda/build.html -:: for a list of environment variables that are set during the build process. diff --git a/conda-recipe/build.sh b/conda-recipe/build.sh deleted file mode 100644 index b7920393..00000000 --- a/conda-recipe/build.sh +++ /dev/null @@ -1,8 +0,0 @@ -#!/bin/bash - -$PYTHON setup.py install - -# Add more build steps here, if they are necessary. - -# See http://docs.continuum.io/conda/build.html -# for a list of environment variables that are set during the build process. diff --git a/conda-recipe/meta.yaml b/conda-recipe/meta.yaml deleted file mode 100644 index 2836e4ff..00000000 --- a/conda-recipe/meta.yaml +++ /dev/null @@ -1,53 +0,0 @@ -{% set setupdata = load_setup_py_data() %} - -package: - name: diffpy.utils - version: {{ setupdata['version'] }} - -source: - # git_url: https://github.com/diffpy/diffpy.utils - git_url: .. - -build: - skip: True # [not py3k] - - # If this is a new build for the same version, increment the build - # number. If you do not include this key, it defaults to 0. - # number: 0 - -requirements: - build: - - python - - setuptools - - run: - - python - - setuptools - - numpy >=1.3 - -test: - # Python imports - imports: - - diffpy.utils - - diffpy.utils.parsers - - diffpy.utils.tests - - commands: - # You can put test commands to be run here. Use this to test that the - # entry points work. - - # You can also put a file called run_test.py in the recipe that will be run - # at test time. - - requires: - # Put any additional test requirements here. For example - # - nose - -about: - home: https://github.com/diffpy/diffpy.utils/ - summary: Shared utilities for diffpy packages. - license: Modified BSD License - license_file: LICENSE.txt - -# See http://docs.continuum.io/conda/build.html -# for more information about meta.yaml. diff --git a/conda-recipe/run_test.py b/conda-recipe/run_test.py deleted file mode 100644 index b9424475..00000000 --- a/conda-recipe/run_test.py +++ /dev/null @@ -1,4 +0,0 @@ -#!/usr/bin/env python3 - -import diffpy.utils.tests -assert diffpy.utils.tests.test().wasSuccessful() diff --git a/devutils/makesdist b/devutils/makesdist deleted file mode 100755 index b21afdd8..00000000 --- a/devutils/makesdist +++ /dev/null @@ -1,54 +0,0 @@ -#!/usr/bin/env python3 - -'''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 sys -import os -import subprocess -import glob -import tarfile -import gzip - -BASEDIR = os.path.dirname(os.path.dirname(os.path.realpath(__file__))) -sys.path.insert(0, BASEDIR) - -from setup import versiondata, FALLBACK_VERSION -timestamp = versiondata.getint('DEFAULT', 'timestamp') - -vfb = versiondata.get('DEFAULT', 'version').split('.post')[0] + '.post0' -emsg = "Invalid FALLBACK_VERSION. Expected %r got %r." -assert vfb == FALLBACK_VERSION, emsg % (vfb, FALLBACK_VERSION) - -def inform(s): - sys.stdout.write(s) - sys.stdout.flush() - return - -inform('Run "setup.py sdist --formats=tar" ') -cmd_sdist = [sys.executable] + 'setup.py sdist --formats=tar'.split() -ec = subprocess.call(cmd_sdist, cwd=BASEDIR, stdout=open(os.devnull, 'w')) -if ec: sys.exit(ec) -inform("[done]\n") - -tarname = max(glob.glob(BASEDIR + '/dist/*.tar'), key=os.path.getmtime) - -tfin = tarfile.open(tarname) -fpout = gzip.GzipFile(tarname + '.gz', 'w', mtime=0) -tfout = tarfile.open(fileobj=fpout, mode='w') - -def fixtarinfo(tinfo): - tinfo.uid = tinfo.gid = 0 - tinfo.uname = tinfo.gname = 'root' - tinfo.mtime = timestamp - tinfo.mode &= ~0o022 - return tinfo - -inform('Filter %s --> %s.gz ' % (2 * (os.path.basename(tarname),))) -for ti in tfin: - tfout.addfile(fixtarinfo(ti), tfin.extractfile(ti)) - -tfin.close() -os.remove(tarname) -inform("[done]\n") diff --git a/doc/manual/Makefile b/doc/manual/Makefile deleted file mode 100644 index 00a6ed10..00000000 --- a/doc/manual/Makefile +++ /dev/null @@ -1,193 +0,0 @@ -# Makefile for Sphinx documentation -# - -# You can set these variables from the command line. -SPHINXOPTS = -SPHINXBUILD = sphinx-build -PAPER = -BUILDDIR = build - -# User-friendly check for sphinx-build -ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1) -$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/) -endif - -# Internal variables. -PAPEROPT_a4 = -D latex_paper_size=a4 -PAPEROPT_letter = -D latex_paper_size=letter -ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source -# the i18n builder cannot share the environment and doctrees with the others -I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source - -.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext - -help: - @echo "Please use \`make ' where is one of" - @echo " html to make standalone HTML files" - @echo " dirhtml to make HTML files named index.html in directories" - @echo " singlehtml to make a single large HTML file" - @echo " pickle to make pickle files" - @echo " json to make JSON files" - @echo " htmlhelp to make HTML files and a HTML help project" - @echo " qthelp to make HTML files and a qthelp project" - @echo " devhelp to make HTML files and a Devhelp project" - @echo " epub to make an epub" - @echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter" - @echo " latexpdf to make LaTeX files and run them through pdflatex" - @echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx" - @echo " text to make text files" - @echo " man to make manual pages" - @echo " texinfo to make Texinfo files" - @echo " info to make Texinfo files and run them through makeinfo" - @echo " gettext to make PO message catalogs" - @echo " changes to make an overview of all changed/added/deprecated items" - @echo " xml to make Docutils-native XML files" - @echo " pseudoxml to make pseudoxml-XML files for display purposes" - @echo " linkcheck to check all external links for integrity" - @echo " doctest to run all doctests embedded in the documentation (if enabled)" - -clean: - rm -rf $(BUILDDIR)/* - -html: - $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." - -dirhtml: - $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml - @echo - @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." - -singlehtml: - $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml - @echo - @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." - -pickle: - $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle - @echo - @echo "Build finished; now you can process the pickle files." - -json: - $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json - @echo - @echo "Build finished; now you can process the JSON files." - -htmlhelp: - $(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp - @echo - @echo "Build finished; now you can run HTML Help Workshop with the" \ - ".hhp project file in $(BUILDDIR)/htmlhelp." - -qthelp: - $(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp - @echo - @echo "Build finished; now you can run "qcollectiongenerator" with the" \ - ".qhcp project file in $(BUILDDIR)/qthelp, like this:" - @echo "# qcollectiongenerator $(BUILDDIR)/qthelp/diffpyutils.qhcp" - @echo "To view the help file:" - @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/diffpyutils.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/diffpyutils" - @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/diffpyutils" - @echo "# devhelp" - -epub: - $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub - @echo - @echo "Build finished. The epub file is in $(BUILDDIR)/epub." - -latex: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo - @echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex." - @echo "Run \`make' in that directory to run these through (pdf)latex" \ - "(use \`make latexpdf' here to do that automatically)." - -latexpdf: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through pdflatex..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -latexpdfja: - $(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex - @echo "Running LaTeX files through platex and dvipdfmx..." - $(MAKE) -C $(BUILDDIR)/latex all-pdf-ja - @echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex." - -text: - $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text - @echo - @echo "Build finished. The text files are in $(BUILDDIR)/text." - -man: - $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man - @echo - @echo "Build finished. The manual pages are in $(BUILDDIR)/man." - -texinfo: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo - @echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo." - @echo "Run \`make' in that directory to run these through makeinfo" \ - "(use \`make info' here to do that automatically)." - -info: - $(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo - @echo "Running Texinfo files through makeinfo..." - make -C $(BUILDDIR)/texinfo info - @echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo." - -gettext: - $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale - @echo - @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." - -changes: - $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes - @echo - @echo "The overview file is in $(BUILDDIR)/changes." - -linkcheck: - $(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck - @echo - @echo "Link check complete; look for any errors in the above output " \ - "or in $(BUILDDIR)/linkcheck/output.txt." - -doctest: - $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest - @echo "Testing of doctests in the sources finished, look at the " \ - "results in $(BUILDDIR)/doctest/output.txt." - -# Manual publishing to the gh-pages branch - -GITREPOPATH = $(shell cd $(CURDIR) && git rev-parse --git-dir) -GITREMOTE = origin -GITREMOTEURL = $(shell git config --get remote.$(GITREMOTE).url) -GITLASTCOMMIT = $(shell git rev-parse --short HEAD) - -publish: - @test -d build/html || \ - ( echo >&2 "Run 'make html' first!"; false ) - git show-ref --verify --quiet refs/heads/gh-pages || \ - git branch --track gh-pages $(GITREMOTE)/gh-pages - test -d build/gh-pages || \ - git clone -s -b gh-pages $(GITREPOPATH) build/gh-pages - cd build/gh-pages && \ - git pull $(GITREMOTEURL) gh-pages - rsync -acv --delete --exclude=.git --exclude=.rsync-exclude \ - --exclude-from=build/gh-pages/.rsync-exclude \ - --link-dest=$(CURDIR)/build/html build/html/ build/gh-pages/ - cd build/gh-pages && \ - git add --all . && \ - git diff --cached --quiet || \ - git commit -m "Sync with the source at $(GITLASTCOMMIT)." - cd build/gh-pages && \ - git push origin gh-pages diff --git a/doc/manual/source/api/diffpy.rst b/doc/manual/source/api/diffpy.rst deleted file mode 100644 index bb109070..00000000 --- a/doc/manual/source/api/diffpy.rst +++ /dev/null @@ -1,17 +0,0 @@ -diffpy package -============== - -Subpackages ------------ - -.. toctree:: - - diffpy.utils - -Module contents ---------------- - -.. automodule:: diffpy - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/manual/source/api/diffpy.utils.parsers.rst b/doc/manual/source/api/diffpy.utils.parsers.rst deleted file mode 100644 index 07e277c4..00000000 --- a/doc/manual/source/api/diffpy.utils.parsers.rst +++ /dev/null @@ -1,30 +0,0 @@ -diffpy.utils.parsers package -============================ - -Submodules ----------- - -diffpy.utils.parsers.loaddata module ------------------------------------- - -.. automodule:: diffpy.utils.parsers.loaddata - :members: - :undoc-members: - :show-inheritance: - -diffpy.utils.parsers.resample module ------------------------------------- - -.. automodule:: diffpy.utils.parsers.resample - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: diffpy.utils.parsers - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/manual/source/api/diffpy.utils.rst b/doc/manual/source/api/diffpy.utils.rst deleted file mode 100644 index 95308b15..00000000 --- a/doc/manual/source/api/diffpy.utils.rst +++ /dev/null @@ -1,30 +0,0 @@ -diffpy.utils package -==================== - -Subpackages ------------ - -.. toctree:: - - diffpy.utils.parsers - diffpy.utils.wx - -Submodules ----------- - -diffpy.utils.version module ---------------------------- - -.. automodule:: diffpy.utils.version - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: diffpy.utils - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/manual/source/api/diffpy.utils.wx.rst b/doc/manual/source/api/diffpy.utils.wx.rst deleted file mode 100644 index 6911ca52..00000000 --- a/doc/manual/source/api/diffpy.utils.wx.rst +++ /dev/null @@ -1,22 +0,0 @@ -diffpy.utils.wx package -======================= - -Submodules ----------- - -diffpy.utils.wx.gridutils module --------------------------------- - -.. automodule:: diffpy.utils.wx.gridutils - :members: - :undoc-members: - :show-inheritance: - - -Module contents ---------------- - -.. automodule:: diffpy.utils.wx - :members: - :undoc-members: - :show-inheritance: diff --git a/doc/manual/source/api/modules.rst b/doc/manual/source/api/modules.rst deleted file mode 100644 index 23fa663f..00000000 --- a/doc/manual/source/api/modules.rst +++ /dev/null @@ -1,7 +0,0 @@ -diffpy -====== - -.. toctree:: - :maxdepth: 4 - - diffpy diff --git a/doc/manual/source/conf.py b/doc/manual/source/conf.py deleted file mode 100644 index 15503d25..00000000 --- a/doc/manual/source/conf.py +++ /dev/null @@ -1,278 +0,0 @@ -#!/usr/bin/env python -# -*- coding: utf-8 -*- -# -# diffpy.utils 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 os -import time - -# If extensions (or modules to document with autodoc) are in another directory, -# add these directories to sys.path here. If the directory is relative to the -# documentation root, use os.path.abspath to make it absolute, like shown here. -#sys.path.insert(0, os.path.abspath('.')) -sys.path.insert(0, os.path.abspath('../../..')) - -# abbreviations -ab_authors = 'Pavol Juhás, Timur Davis, Christopher L. Farrow, Simon J.L. Billinge group' - -# -- 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.intersphinx', - 'sphinx.ext.viewcode', -] - -# Add any paths that contain templates here, relative to this directory. -templates_path = ['_templates'] - -# The suffix of source filenames. -source_suffix = '.rst' - -# The encoding of source files. -#source_encoding = 'utf-8-sig' - -# The master toctree document. -master_doc = 'index' - -# General information about the project. -project = 'diffpy.utils' -copyright = '%Y, Brookhaven National Laboratory' - -# 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. -from setup import versiondata -fullversion = versiondata.get('DEFAULT', 'version') -# 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_seconds = versiondata.getint('DEFAULT', 'timestamp') -today = time.strftime('%B %d, %Y', time.localtime(today_seconds)) -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.utils'] - -# 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 = 'default' - -# 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 = {} -html_theme_options = {'collapsiblesidebar' : '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. -htmlhelp_basename = 'diffpyutilsdoc' - - -# -- 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.utils.tex', 'diffpy.utils 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.utils', 'diffpy.utils 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.utils', 'diffpy.utils Documentation', - ab_authors, 'diffpy.utils', '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/manual/source/index.rst b/doc/manual/source/index.rst deleted file mode 100644 index 8daa2fd7..00000000 --- a/doc/manual/source/index.rst +++ /dev/null @@ -1,58 +0,0 @@ -.. diffpy.utils documentation master file, created by - sphinx-quickstart on Thu Jan 30 15:49:41 2014. - You can adapt this file completely to your liking, but it should at least - contain the root `toctree` directive. - - -#################################################### -diffpy.utils's documentation! -#################################################### - -Software version |release|. - -Last updated |today|. - -diffpy.utils - general purpose shared utilities for the diffpy libraries. - -The diffpy.utils package provides functions for extracting array data from -variously formatted text files and wx GUI utilities used by the PDFgui -program. The package also includes interpolation function based on the -Whittaker-Shannon formula that can be used to resample a PDF or other profile -function over a new grid. - - -=================== -Disclaimer -=================== - -.. literalinclude:: ../../../LICENSE.txt - -================ -Acknowledgments -================ - -Developers ------------ - -diffpy.Structure is developed and maintained by - -.. literalinclude:: ../../../AUTHORS.txt - -====================================== -Installation -====================================== - -See the `README.rst `_ -file included with the distribution. - -====================================== -API and Index -====================================== - -.. toctree:: - :maxdepth: 3 - - api/diffpy.utils.rst - -* :ref:`genindex` -* :ref:`search` diff --git a/setup.py b/setup.py deleted file mode 100755 index f43ccd6d..00000000 --- a/setup.py +++ /dev/null @@ -1,114 +0,0 @@ -#!/usr/bin/env python3 - -"""utils - small shared utilities for other diffpy packages - -Packages: diffpy.utils -""" - -import os -import re -import sys -from setuptools import setup, find_packages - -# Use this version when git data are not available, like in git zip archive. -# Update when tagging a new release. -FALLBACK_VERSION = '3.0a2.post0' - -# 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/utils/version.cfg') -gitarchivecfgfile = os.path.join(MYDIR, '.gitarchive.cfg') - - -def gitinfo(): - from subprocess import Popen, PIPE - kw = dict(stdout=PIPE, cwd=MYDIR) - proc = Popen(['git', 'describe', '--match=v[[:digit:]]*'], **kw) - desc = proc.stdout.read().decode() - proc = Popen(['git', 'log', '-1', '--format=%H %ct %ci'], **kw) - glog = proc.stdout.read().decode() - 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 sys.version_info[0] >= 3: - 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']) - cp.write(open(versioncfgfile, 'w')) - return cp - -versiondata = getversioncfg() - -# define distribution -setup_args = dict( - name = "diffpy.utils", - version = versiondata.get('DEFAULT', 'version'), - packages = [('diffpy.' + p) for p in find_packages('src/diffpy')], - package_dir = {'' : 'src'}, - test_suite = 'diffpy.utils.tests', - include_package_data = True, - zip_safe = False, - author = 'Simon J.L. Billinge group', - author_email = 'sb2896@columbia.edu', - maintainer = 'Pavol Juhas', - maintainer_email = 'pavol.juhas@gmail.com', - description = "Shared utilities for diffpy packages.", - license = 'BSD-style license', - url = "https://github.com/diffpy/diffpy.utils/", - keywords = "text data parsers wx grid", - 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 :: Science/Research', - 'License :: OSI Approved :: BSD License', - 'Operating System :: MacOS :: MacOS X', - 'Operating System :: Microsoft :: Windows', - 'Operating System :: POSIX', - 'Operating System :: Unix', - 'Programming Language :: Python :: 3.4', - 'Programming Language :: Python :: 3.5', - 'Programming Language :: Python :: 3.6', - 'Topic :: Scientific/Engineering :: Physics', - ], -) - -if __name__ == '__main__': - setup(**setup_args) - -# End of file diff --git a/src/diffpy/utils/__init__.py b/src/diffpy/utils/__init__.py deleted file mode 100644 index ed92db70..00000000 --- a/src/diffpy/utils/__init__.py +++ /dev/null @@ -1,29 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Chris Farrow, Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Smalled shared functions for use by other diffpy packages. - -Subpackages: - -parsers -- various utilities related to data parsing and manipulation. -""" - -# package version -from diffpy.utils.version import __version__ - -# silence the pyflakes syntax checker -assert __version__ or True - -# End of file diff --git a/src/diffpy/utils/parsers/__init__.py b/src/diffpy/utils/parsers/__init__.py deleted file mode 100644 index 292c9ada..00000000 --- a/src/diffpy/utils/parsers/__init__.py +++ /dev/null @@ -1,25 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Chris Farrow -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Various utilities related to data parsing and manipulation. -""" - -from .loaddata import loadData -from .resample import resample - -# silence the pyflakes syntax checker -assert loadData or resample or True - -# End of file diff --git a/src/diffpy/utils/parsers/loaddata.py b/src/diffpy/utils/parsers/loaddata.py deleted file mode 100644 index e4d29520..00000000 --- a/src/diffpy/utils/parsers/loaddata.py +++ /dev/null @@ -1,250 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Timur Davis, Chris Farrow, Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -import numpy - - -def loadData(filename, minrows=10, **kwargs): - """Find and load data from a text file. - - The data reading starts at the first matrix block of at least minrows rows - and constant number of columns. This seems to work for most of the - datafiles including those generated by PDFGetX2. - - filename -- name of the file we want to load data from. - minrows -- minimum number of rows in the first data block. - All rows must have the same number of floating point values. - usecols -- zero-based index of columns to be loaded, by default use - all detected columns. The reading skips data blocks that - do not have the usecols-specified columns. - unpack -- return data as a sequence of columns that allows tuple - unpacking such as x, y = loadData(FILENAME, unpack=True). - Note transposing the loaded array as loadData(FILENAME).T - has the same effect. - kwargs -- keyword arguments that are passed to numpy.loadtxt - - Return a numpy array of the data. - See also numpy.loadtxt for more details. - """ - from numpy import array, loadtxt - # determine the arguments - delimiter = kwargs.get('delimiter') - usecols = kwargs.get('usecols') - # required at least one column of floating point values - mincv = (1, 1) - # but if usecols is specified, require sufficient number of columns - # where the used columns contain floats - if usecols is not None: - hiidx = max(-min(usecols), max(usecols) + 1) - mincv = (hiidx, len(set(usecols))) - # Check if a line consists of floats only and return their count - # Return zero if some strings cannot be converted. - def countcolumnsvalues(line): - try: - words = line.split(delimiter) - # remove trailing blank columns - while words and not words[-1].strip(): - words.pop(-1) - nc = len(words) - if usecols is not None: - nv = len([float(words[i]) for i in usecols]) - else: - nv = len([float(w) for w in words]) - except (IndexError, ValueError): - nc = nv = 0 - return nc, nv - # make sure fid gets cleaned up - with open(filename, 'rb') as fid: - # search for the start of datablock - start = ncvblock = None - fpos = (0, 0) - nrows = 0 - for line in fid: - fpos = (fpos[1], fpos[1] + len(line)) - line = line.decode() - ncv = countcolumnsvalues(line) - if ncv < mincv: - start = None - continue - # ncv is acceptable here, require the same number of columns - # throughout the datablock - if start is None or ncv != ncvblock: - ncvblock = ncv - nrows = 0 - start = fpos[0] - nrows += 1 - # block was found here! - if nrows >= minrows: - break - # Return an empty array when no data found. - # loadtxt would otherwise raise an exception on loading from EOF. - if start is None: - rv = array([], dtype=float) - else: - fid.seek(start) - # always use usecols argument so that loadtxt does not crash - # in case of trailing delimiters. - kwargs.setdefault('usecols', list(range(ncvblock[0]))) - rv = loadtxt(fid, **kwargs) - return rv - - -class TextDataLoader(object): - '''Smart loading of a text data with possibly multiple datasets. - ''' - - minrows = 10 - usecols = None - skiprows = None - - def __init__(self, minrows=None, usecols=None, skiprows=None): - if minrows is not None: - self.minrows = minrows - if usecols is not None: - self.usecols = tuple(usecols) - if skiprows is not None: - self.skiprows = skiprows - # data items - self._reset() - return - - - def _reset(self): - self.filename = '' - self.headers = [] - self.datasets = [] - self._resetvars() - return - - - def _resetvars(self): - self._filename = '' - self._lines = None - self._splitlines = None - self._words = None - self._linerecs = None - self._wordrecs = None - return - - - def read(self, filename): - with open(filename, 'rb') as fp: - self.readfp(fp) - return - - - def readfp(self, fp, append=False): - self._reset() - # try to read lines from fp first - self._lines = fp.readlines() - # and if good, assign filename - self.filename = getattr(fp, 'name', '') - self._words = ''.join(self._lines).split() - self._splitlines = [line.split() for line in self._lines] - self._findDataBlocks() - return - - - def _findDataBlocks(self): - mincols = 1 - if self.usecols is not None and len(self.usecols): - mincols = max(mincols, max(self.usecols) + 1) - mincols = max(mincols, abs(min(self.usecols))) - nlines = len(self._lines) - nwords = len(self._words) - # idx - line index, nw0, nw1 - index of the first and last word, - # nf - number of words, ok - has data - self._linerecs = numpy.recarray((nlines,), dtype=[('idx', int), - ('nw0', int), ('nw1', int), ('nf', int), ('ok', bool)]) - lr = self._linerecs - lr.idx = numpy.arange(nlines) - lr.nf = [len(sl) for sl in self._splitlines] - lr.nw1 = lr.nf.cumsum() - lr.nw0 = lr.nw1 - lr.nf - lr.ok = True - # word records - lw = self._wordrecs = numpy.recarray((nwords,), dtype=[('idx', int), - ('line', int), ('col', int), ('ok', bool), ('value', float)]) - lw.idx = numpy.arange(nwords) - n1 = numpy.zeros(nwords, dtype=bool) - n1[lr.nw1[:-1]] = True - lw.line = n1.cumsum() - lw.col = lw.idx - lr.nw0[lw.line] - lw.ok = True - values = nwords * [0.0] - for i, w in enumerate(self._words): - try: - values[i] = float(w) - except: - lw.ok[i] = False - # prune lines that have a non-float values: - lw.values = values - if self.usecols is None: - badlines = lw.line[~lw.ok] - lr.ok[badlines] = False - else: - for col in self.usecols: - badlines = lw.line[(lw.col == col) & ~lw.ok] - lr.ok[badlines] = False - lr1 = lr[lr.nf >= mincols] - okb = numpy.r_[lr1.ok[:1], lr1.ok[1:] & ~lr1.ok[:-1], False] - oke = numpy.r_[False, ~lr1.ok[1:] & lr1.ok[:-1], lr1.ok[-1:]] - blockb = numpy.r_[True, lr1.nf[1:] != lr1.nf[:-1], False] - blocke = numpy.r_[False, blockb[1:-1], True] - beg = numpy.nonzero(okb | blockb)[0] - end = numpy.nonzero(oke | blocke)[0] - rowcounts = end - beg - assert not numpy.any(rowcounts < 0) - goodrows = (rowcounts >= self.minrows) - begend = numpy.transpose([beg, end - 1])[goodrows] - hbeg = 0 - for dbeg, dend in begend: - bb1 = lr1[dbeg] - ee1 = lr1[dend] - hend = bb1.idx - header = ''.join(self._lines[hbeg:hend]) - hbeg = ee1.idx + 1 - if self.usecols is None: - data = numpy.reshape(lw.value[bb1.nw0:ee1.nw1], (-1, bb1.nf)) - else: - tdata = numpy.empty((len(self.usecols), dend - dbeg), dtype=float) - for j, trow in zip(self.usecols, tdata): - j %= bb1.nf - trow[:] = lw.value[bb1.nw0 + j : ee1.nw1 : bb1.nf] - data = tdata.transpose() - self.headers.append(header) - self.datasets.append(data) - # finish reading to a last header and empty dataset - if hbeg < len(self._lines): - header = ''.join(self._lines[hbeg:]) - data = numpy.empty(0, dtype=float) - self.headers.append(header) - self.datasets.append(data) - return - - -# End of class TextDataLoader - -def isfloat(s): - '''True if s is convertible to float. - ''' - try: - float(s) - return True - except: - pass - return False - -# End of file diff --git a/src/diffpy/utils/parsers/resample.py b/src/diffpy/utils/parsers/resample.py deleted file mode 100644 index 856ae07e..00000000 --- a/src/diffpy/utils/parsers/resample.py +++ /dev/null @@ -1,107 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Chris Farrow -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Various utilities related to data parsing and manipulation.""" - -import numpy - -# NOTE - this should be faster than resample below and conforms more closely to -# numpy.interp. I'm keeping resample for legacy reasons. -def wsinterp(x, xp, fp, left = None, right = None): - """One-dimensional Whittaker-Shannon interpolation. - - This uses the Whittaker-Shannon interpolation formula to interpolate the - value of fp (array), which is defined over xp (array), at x (array or - float). - - Returns the interpolated array with dimensions of x. - - """ - scalar = numpy.isscalar(x) - if scalar: - x = numpy.array(x) - x.resize(1) - # shape = (nxp, nx), nxp copies of x data span axis 1 - u = numpy.resize(x, (len(xp), len(x))) - # Must take transpose of u for proper broadcasting with xp. - # shape = (nx, nxp), v(xp) data spans axis 1 - v = (xp - u.T) / (xp[1] - xp[0]) - # shape = (nx, nxp), m(v) data spans axis 1 - m = fp * numpy.sinc(v) - # Sum over m(v) (axis 1) - fp_at_x = numpy.sum(m, axis = 1) - - # Enforce left and right - if left is None: left = fp[0] - fp_at_x[x < xp[0]] = left - if right is None: right = fp[-1] - fp_at_x[x > xp[-1]] = right - - # Return a float if we got a float - if scalar: return float(fp_at_x) - - return fp_at_x - -def resample(r, s, dr): - """Resample a PDF on a new grid. - - This uses the Whittaker-Shannon interpolation formula to put s1 on a new - grid if dr is less than the sampling interval of r1, or linear - interpolation if dr is greater than the sampling interval of r1. - - r -- The r-grid used for s1 - s -- The signal to be resampled - dr -- The new sampling interval - - Returns resampled (r, s) - - """ - - dr0 = r[1] - r[0] - - if dr0 < dr: - rnew = numpy.arange(r[0], r[-1]+0.5*dr, dr) - snew = numpy.interp(rnew, r, s) - return rnew, snew - - elif dr0 > dr: - - # Tried to pad the end of s to dampen, but nothing works. - #m = (s[-1] - s[-2]) / dr0 - #b = (s[-2] * r[-1] - s[-1] * r[-2]) / dr0 - #rpad = r[-1] + numpy.arange(1, len(s))*dr0 - #spad = rpad * m + b - #spad = numpy.concatenate([s,spad]) - #rnew = numpy.arange(0, rpad[-1], dr) - #snew = numpy.zeros_like(rnew) - ## Accomodate for the fact that r[0] might not be 0 - #u = (rnew-r[0]) / dr0 - #for n in range(len(spad)): - # snew += spad[n] * numpy.sinc(u - n) - - #sel = numpy.logical_and(rnew >= r[0], rnew <= r[-1]) - - rnew = numpy.arange(0, r[-1], dr) - snew = numpy.zeros_like(rnew) - u = (rnew-r[0]) / dr0 - for n in range(len(s)): - snew += s[n] * numpy.sinc(u - n) - sel = numpy.logical_and(rnew >= r[0], rnew <= r[-1]) - return rnew[sel], snew[sel] - - # If we got here, then no resampling is required - return r.copy(), s.copy() - -# End of file diff --git a/src/diffpy/utils/tests/__init__.py b/src/diffpy/utils/tests/__init__.py deleted file mode 100644 index 29611447..00000000 --- a/src/diffpy/utils/tests/__init__.py +++ /dev/null @@ -1,79 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2011 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Unit tests for diffpy.utils. -""" - -import unittest - - -def testsuite(pattern=''): - '''Create a unit tests suite for diffpy.utils package. - - Parameters - ---------- - pattern : str, optional - Regular expression pattern for selecting test cases. - Select all tests when empty. Ignore the pattern when - any of unit test modules fails to import. - - Returns - ------- - suite : `unittest.TestSuite` - The TestSuite object containing the matching tests. - ''' - import re - from os.path import dirname - from itertools import chain - from pkg_resources import resource_filename - loader = unittest.defaultTestLoader - thisdir = resource_filename(__name__, '') - depth = __name__.count('.') + 1 - topdir = thisdir - for i in range(depth): - topdir = dirname(topdir) - suite_all = loader.discover(thisdir, top_level_dir=topdir) - # always filter the suite by pattern to test-cover the selection code. - suite = unittest.TestSuite() - rx = re.compile(pattern) - tsuites = list(chain.from_iterable(suite_all)) - tsok = all(isinstance(ts, unittest.TestSuite) for ts in tsuites) - if not tsok: # pragma: no cover - return suite_all - tcases = chain.from_iterable(tsuites) - for tc in tcases: - tcwords = tc.id().rsplit('.', 2) - shortname = '.'.join(tcwords[-2:]) - if rx.search(shortname): - suite.addTest(tc) - # verify all tests are found for an empty pattern. - assert pattern or suite_all.countTestCases() == suite.countTestCases() - return suite - - -def test(): - '''Execute all unit tests for the diffpy.utils package. - - Returns - ------- - result : `unittest.TestResult` - ''' - suite = testsuite() - runner = unittest.TextTestRunner() - result = runner.run(suite) - return result - - -# End of file diff --git a/src/diffpy/utils/tests/debug.py b/src/diffpy/utils/tests/debug.py deleted file mode 100644 index fc8595b2..00000000 --- a/src/diffpy/utils/tests/debug.py +++ /dev/null @@ -1,33 +0,0 @@ -#!/usr/bin/env python -############################################################################## -# -# diffpy.utils Complex Modeling Initiative -# (c) 2016 Brookhaven Science Associates, -# Brookhaven National Laboratory. -# All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE.txt for license information. -# -############################################################################## - -""" -Convenience module for debugging the unit tests using - -python -m diffpy.utils.tests.debug - -Exceptions raised by failed tests or other errors are not caught. -""" - - -if __name__ == '__main__': - import sys - from diffpy.utils.tests import testsuite - pattern = sys.argv[1] if len(sys.argv) > 1 else '' - suite = testsuite(pattern) - suite.debug() - - -# End of file diff --git a/src/diffpy/utils/tests/run.py b/src/diffpy/utils/tests/run.py deleted file mode 100644 index d40ce87d..00000000 --- a/src/diffpy/utils/tests/run.py +++ /dev/null @@ -1,27 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2012 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Convenience module for executing all unit tests with - -python -m diffpy.utils.tests.run -""" - -if __name__ == '__main__': - import sys - from diffpy.utils.tests import test - # produce zero exit code for a successful test - sys.exit(not test().wasSuccessful()) - -# End of file diff --git a/src/diffpy/utils/tests/testdata/loaddata01.txt b/src/diffpy/utils/tests/testdata/loaddata01.txt deleted file mode 100644 index 5ad25e05..00000000 --- a/src/diffpy/utils/tests/testdata/loaddata01.txt +++ /dev/null @@ -1,5 +0,0 @@ -1 -2 -3 31 -4 32 -5 33 diff --git a/src/diffpy/utils/tests/testhelpers.py b/src/diffpy/utils/tests/testhelpers.py deleted file mode 100644 index b0c25456..00000000 --- a/src/diffpy/utils/tests/testhelpers.py +++ /dev/null @@ -1,26 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2011 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Helper routines for running other unit tests. -""" - -# helper functions - -def datafile(filename): - from pkg_resources import resource_filename - rv = resource_filename(__name__, "testdata/" + filename) - return rv - -# End of file diff --git a/src/diffpy/utils/tests/testloaddata.py b/src/diffpy/utils/tests/testloaddata.py deleted file mode 100644 index fbdfecf5..00000000 --- a/src/diffpy/utils/tests/testloaddata.py +++ /dev/null @@ -1,52 +0,0 @@ -#!/usr/bin/env python3 - -"""Unit tests for diffpy.utils.parsers.loaddata -""" - -import unittest -import numpy -from diffpy.utils.parsers import loadData -from diffpy.utils.tests.testhelpers import datafile - -loaddata01 = datafile('loaddata01.txt') - -############################################################################## -class TestLoadData(unittest.TestCase): - - def test_loadData_default(self): - """check loadData() with default options - """ - d2c = numpy.array([[3, 31], [4, 32], [5, 33]]) - self.assertRaises(IOError, loadData, 'doesnotexist') - # the default minrows=10 makes it read from the third line - d = loadData(loaddata01) - self.assertTrue(numpy.array_equal(d2c, d)) - # the usecols=(0, 1) would make it read from the third line - d = loadData(loaddata01, minrows=1, usecols=(0, 1)) - self.assertTrue(numpy.array_equal(d2c, d)) - # check the effect of usecols effect - d = loadData(loaddata01, usecols=(0,)) - self.assertTrue(numpy.array_equal(d2c[:,0], d)) - d = loadData(loaddata01, usecols=(1,)) - self.assertTrue(numpy.array_equal(d2c[:,1], d)) - return - - - def test_loadData_1column(self): - """check loading of one-column data. - """ - d1c = numpy.arange(1, 6) - d = loadData(loaddata01, usecols=[0], minrows=1) - self.assertTrue(numpy.array_equal(d1c, d)) - d = loadData(loaddata01, usecols=[0], minrows=2) - self.assertTrue(numpy.array_equal(d1c, d)) - d = loadData(loaddata01, usecols=[0], minrows=3) - self.assertFalse(numpy.array_equal(d1c, d)) - return - -# End of class TestRoutines - -if __name__ == '__main__': - unittest.main() - -# End of file diff --git a/src/diffpy/utils/version.py b/src/diffpy/utils/version.py deleted file mode 100644 index 9911fcd1..00000000 --- a/src/diffpy/utils/version.py +++ /dev/null @@ -1,55 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2011 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt 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) - -__version__ = cp['version'] -__date__ = cp['date'] -__git_commit__ = cp['commit'] -__timestamp__ = int(cp['timestamp']) - -# TODO remove deprecated __gitsha__ in version 3.1. -__gitsha__ = __git_commit__ - -del cp, fcfg, fp, kwords - -# End of file diff --git a/src/diffpy/utils/wx/__init__.py b/src/diffpy/utils/wx/__init__.py deleted file mode 100644 index 15bee629..00000000 --- a/src/diffpy/utils/wx/__init__.py +++ /dev/null @@ -1,21 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2010 The Trustees of Columbia University -# in the City of New York. All rights reserved. -# -# File coded by: Chris Farrow -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Utilities related wx Python GUIs. - -gridutils -- selection management in wx.grid.Grid -""" - -# End of file diff --git a/src/diffpy/utils/wx/gridutils.py b/src/diffpy/utils/wx/gridutils.py deleted file mode 100644 index 59d8c92a..00000000 --- a/src/diffpy/utils/wx/gridutils.py +++ /dev/null @@ -1,158 +0,0 @@ -#!/usr/bin/env python3 -############################################################################## -# -# diffpy.utils by DANSE Diffraction group -# Simon J. L. Billinge -# (c) 2006 trustees of the Michigan State University. -# All rights reserved. -# -# File coded by: Chris Farrow, Pavol Juhas -# -# See AUTHORS.txt for a list of people who contributed. -# See LICENSE_DANSE.txt for license information. -# -############################################################################## - -"""Common functions for manipulating wx.grid.Grid. -""" - -import wx - - -def getSelectionRows(grid): - """Indices of the rows that have any cell selected. - """ - rows = grid.GetNumberRows() - rset = set() - if grid.GetSelectedCols(): - rset.update(range(rows)) - rset.update(grid.GetSelectedRows()) - for r, c in grid.GetSelectedCells(): - rset.add(r) - blocks = zip(grid.GetSelectionBlockTopLeft(), - grid.GetSelectionBlockBottomRight()) - for tl, br in blocks: - rset.update(range(tl[0], br[0] + 1)) - rv = sorted(rset) - return rv - - -def getSelectionColumns(grid): - """Indices of columns that have any cell selected. - """ - cols = grid.GetNumberCols() - cset = set() - if grid.GetSelectedRows(): - cset.update(range(cols)) - cset.update(grid.GetSelectedCols()) - for r, c in grid.GetSelectedCells(): - cset.add(c) - blocks = zip(grid.GetSelectionBlockTopLeft(), - grid.GetSelectionBlockBottomRight()) - for tl, br in blocks: - cset.update(range(tl[1], br[1] + 1)) - rv = sorted(cset) - return rv - - -def getSelectedCells(grid): - """Get list of (row, col) pairs of all selected cells. - Unlike grid.GetSelectedCells this returns them all no matter - how they were selected. - """ - rows = grid.GetNumberRows() - cols = grid.GetNumberCols() - allrows = range(rows) - allcols = range(cols) - rcset = set() - for r in grid.GetSelectedRows(): - rcset.update(zip(cols * [r], allcols)) - for c in grid.GetSelectedCols(): - rcset.update(zip(allrows, rows * [c])) - blocks = zip(grid.GetSelectionBlockTopLeft(), - grid.GetSelectionBlockBottomRight()) - for tl, br in blocks: - brows = range(tl[0], br[0] + 1) - bcols = range(tl[1], br[1] + 1) - rcset.update((r, c) for r in brows for c in bcols) - rcset.update(grid.GetSelectedCells()) - rv = sorted(rcset) - return rv - - -def limitSelectionToRows(grid, indices): - '''Limit selection to the specified row indices. - No action for empty indices. - - grid -- instance of wx.grid.Grid - indices -- list of row indices to be selected, must be sorted and unique. - - No return value. - ''' - import bisect - if not indices: return - rowblocks = _indicesToBlocks(indices) - cindices = getSelectionColumns(grid) or [grid.GetGridCursorCol()] - colblocks = _indicesToBlocks(cindices) - grid.ClearSelection() - for rlo, rhi in rowblocks: - for clo, chi in colblocks: - grid.SelectBlock(rlo, clo, rhi, chi, True) - # move cursor to the selected area - krow = bisect.bisect_left(indices, grid.GetGridCursorRow()) - krow = min(krow, len(indices) - 1) - kcol = bisect.bisect_left(cindices, grid.GetGridCursorCol()) - kcol = min(kcol, len(cindices) - 1) - grid.SetGridCursor(indices[krow], cindices[kcol]) - return - - -def quickResizeColumns(grid, indices): - """Resize the columns that were recently affected by cell changes. - - This is faster than the normal grid AutoSizeColumns, since the latter loops - over the entire grid. In addition, this will not cause a - EVT_GRID_CMD_CELL_CHANGE event to be thrown, which can cause recursion. - This method will only increase column size. - """ - # Get the columns and maximum text width in each one - dc = wx.ScreenDC() - maxSize = {} - for (i, j) in indices: - if j not in maxSize: - renderer = grid.GetCellRenderer(i, j) - attr = grid.GetOrCreateCellAttr(i, j) - size = renderer.GetBestSize(grid, attr, dc, i, j).width - size += 10 # Need a small buffer - maxSize[j] = size - - grid.BeginBatch() - for (j, size) in maxSize.items(): - if size > grid.GetColSize(j): - grid.SetColSize(j, size) - grid.EndBatch() - return - -# Local Helpers -------------------------------------------------------------- - -def _indicesToBlocks(indices): - '''Convert a list of integer indices to a list of (start, stop) tuples. - The (start, stop) tuple defines a continuous block, where the stop index - is included in the block. - - indices -- list of integer indices, must be unique and sorted. - - Return a list of (start, stop) tuples. - ''' - rngs = [] - i0 = -100 - for i in indices: - if i > i0 + 1: - rngs.append([i, i]) - else: - rngs[-1][-1] = i - i0 = i - rv = [tuple(ij) for ij in rngs] - return rv - -# End of file diff --git a/switch-to-master.rst b/switch-to-master.rst new file mode 120000 index 00000000..92cacd28 --- /dev/null +++ b/switch-to-master.rst @@ -0,0 +1 @@ +README.rst \ No newline at end of file