From 7f3581ab92d6a14260ca9b00f3aca0b1c55b53df Mon Sep 17 00:00:00 2001 From: Guido Imperiale Date: Sat, 5 May 2018 23:49:50 +0100 Subject: [PATCH] Boilerplate --- .appveyor.yml | 33 ++++ .gitattributes | 2 + .gitignore | 56 ++++++ .stickler.yml | 5 + .travis.yml | 53 ++++++ LICENSE | 165 ++++++++++++++++ MANIFEST.in.py | 5 + README.md | 2 + ci/.coveragerc | 3 + ci/install_python.ps1 | 97 ++++++++++ ci/requirements-py35.yml | 16 ++ ci/requirements-py36-nodask.yml | 15 ++ ci/requirements-py36-nonumba.yml | 15 ++ ci/requirements-py36.yml | 16 ++ conftest.py | 6 + doc/Makefile | 240 +++++++++++++++++++++++ doc/README.rst | 2 + doc/_static/.gitignore | 5 + doc/_static/style.css | 18 ++ doc/_templates/layout.html | 2 + doc/api.rst | 17 ++ doc/conf.py | 318 +++++++++++++++++++++++++++++++ doc/environment.yml | 15 ++ doc/index.rst | 16 ++ doc/installing.rst | 27 +++ doc/whats-new.rst | 19 ++ readthedocs.yml | 5 + setup.cfg | 17 ++ setup.py | 126 ++++++++++++ xarray_extras/__init__.py | 0 xarray_extras/tests/__init__.py | 0 31 files changed, 1316 insertions(+) create mode 100644 .appveyor.yml create mode 100644 .gitattributes create mode 100644 .gitignore create mode 100644 .stickler.yml create mode 100644 .travis.yml create mode 100644 LICENSE create mode 100644 MANIFEST.in.py create mode 100644 ci/.coveragerc create mode 100644 ci/install_python.ps1 create mode 100644 ci/requirements-py35.yml create mode 100644 ci/requirements-py36-nodask.yml create mode 100644 ci/requirements-py36-nonumba.yml create mode 100644 ci/requirements-py36.yml create mode 100644 conftest.py create mode 100644 doc/Makefile create mode 100644 doc/README.rst create mode 100644 doc/_static/.gitignore create mode 100644 doc/_static/style.css create mode 100644 doc/_templates/layout.html create mode 100644 doc/api.rst create mode 100644 doc/conf.py create mode 100644 doc/environment.yml create mode 100644 doc/index.rst create mode 100644 doc/installing.rst create mode 100644 doc/whats-new.rst create mode 100644 readthedocs.yml create mode 100644 setup.cfg create mode 100644 setup.py create mode 100644 xarray_extras/__init__.py create mode 100644 xarray_extras/tests/__init__.py diff --git a/.appveyor.yml b/.appveyor.yml new file mode 100644 index 0000000..016850b --- /dev/null +++ b/.appveyor.yml @@ -0,0 +1,33 @@ +# CI on Windows via appveyor +# This file was based on Olivier Grisel's python-appveyor-demo +branches: + except: + - fix-docs + +environment: + + matrix: + - PYTHON: "C:\\Python36-conda64" + PYTHON_VERSION: "3.6" + PYTHON_ARCH: "64" + CONDA_ENV: "py36-windows" + +install: + # Install miniconda Python + - "powershell ./ci/install_python.ps1" + + # Prepend newly installed Python to the PATH of this build (this cannot be + # done from inside the powershell script as it would require to restart + # the parent CMD process). + - "SET PATH=%PYTHON%;%PYTHON%\\Scripts;%PATH%" + + # install xarray and dependencies + - "conda env create --file ./ci/requirements-%CONDA_ENV%.yml" + - "activate test_env" + - "conda list" + - "python setup.py install" + +build: false + +test_script: + - "py.test --verbose" diff --git a/.gitattributes b/.gitattributes new file mode 100644 index 0000000..a52f4ca --- /dev/null +++ b/.gitattributes @@ -0,0 +1,2 @@ +# reduce the number of merge conflicts +doc/whats-new.rst merge=union diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..fbc78fa --- /dev/null +++ b/.gitignore @@ -0,0 +1,56 @@ +*.py[cod] +__pycache__ + +# C extensions +*.so + +# Packages +*.egg +*.egg-info +dist +build +eggs +parts +bin +var +sdist +develop-eggs +.installed.cfg +lib +lib64 + +# Installer logs +pip-log.txt + +# Unit test / coverage reports +.coverage +.tox +nosetests.xml +.cache +.ropeproject/ +.tags* +.testmon* +.pytest_cache +dask-worker-space/ + +# asv environments +.asv + +# Translations +*.mo + +# Mr Developer +.mr.developer.cfg +.project +.pydevproject + +# IDEs +.idea +*.swp +.DS_Store +.vscode/ + +# Sync tools +Icon* + +.ipynb_checkpoints diff --git a/.stickler.yml b/.stickler.yml new file mode 100644 index 0000000..596fb12 --- /dev/null +++ b/.stickler.yml @@ -0,0 +1,5 @@ +linters: + flake8: + max-line-length: 79 + fixer: false + ignore: I002 diff --git a/.travis.yml b/.travis.yml new file mode 100644 index 0000000..b07b5ad --- /dev/null +++ b/.travis.yml @@ -0,0 +1,53 @@ +# Based on http://conda.pydata.org/docs/travis.html +language: python +sudo: false # use container based build +notifications: + email: false +branches: + except: + - fix-docs + +matrix: + fast_finish: true + include: + - python: 3.5 + env: CONDA_ENV=py35 + - python: 3.6 + env: CONDA_ENV=py36 + - python: 3.6 + env: CONDA_ENV=py36-nodask + - python: 3.6 + env: CONDA_ENV=py36-nonumba + - python: 3.6 + env: CONDA_ENV=docs + allow_failures: + +before_install: + - wget http://repo.continuum.io/miniconda/Miniconda3-3.16.0-Linux-x86_64.sh -O miniconda.sh; + - bash miniconda.sh -b -p $HOME/miniconda + - export PATH="$HOME/miniconda/bin:$PATH" + - hash -r + - conda config --set always_yes yes --set changeps1 no --set show_channel_urls true + - conda update -q conda + - conda info -a + +install: + - if [[ "$CONDA_ENV" == "docs" ]]; then + conda env create -n test_env --file doc/environment.yml; + else + conda env create -n test_env --file ci/requirements-$CONDA_ENV.yml; + fi + - source activate test_env + - conda list + - pip install --no-deps -e . + +script: + - python -OO -c "import xarray_extras" + - if [[ "$CONDA_ENV" == "docs" ]]; then + conda install -c conda-forge sphinx sphinx_rtd_theme sphinx-gallery numpydoc; + sphinx-build -n -j auto -b html -d _build/doctrees doc _build/html; + else + py.test xarray_extras --cov=xarray_extras --cov-config ci/.coveragerc --cov-report term-missing --verbose $EXTRA_FLAGS; + fi +after_success: + - coveralls diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..0a04128 --- /dev/null +++ b/LICENSE @@ -0,0 +1,165 @@ + GNU LESSER GENERAL PUBLIC LICENSE + Version 3, 29 June 2007 + + Copyright (C) 2007 Free Software Foundation, Inc. + Everyone is permitted to copy and distribute verbatim copies + of this license document, but changing it is not allowed. + + + This version of the GNU Lesser General Public License incorporates +the terms and conditions of version 3 of the GNU General Public +License, supplemented by the additional permissions listed below. + + 0. Additional Definitions. + + As used herein, "this License" refers to version 3 of the GNU Lesser +General Public License, and the "GNU GPL" refers to version 3 of the GNU +General Public License. + + "The Library" refers to a covered work governed by this License, +other than an Application or a Combined Work as defined below. + + An "Application" is any work that makes use of an interface provided +by the Library, but which is not otherwise based on the Library. +Defining a subclass of a class defined by the Library is deemed a mode +of using an interface provided by the Library. + + A "Combined Work" is a work produced by combining or linking an +Application with the Library. The particular version of the Library +with which the Combined Work was made is also called the "Linked +Version". + + The "Minimal Corresponding Source" for a Combined Work means the +Corresponding Source for the Combined Work, excluding any source code +for portions of the Combined Work that, considered in isolation, are +based on the Application, and not on the Linked Version. + + The "Corresponding Application Code" for a Combined Work means the +object code and/or source code for the Application, including any data +and utility programs needed for reproducing the Combined Work from the +Application, but excluding the System Libraries of the Combined Work. + + 1. Exception to Section 3 of the GNU GPL. + + You may convey a covered work under sections 3 and 4 of this License +without being bound by section 3 of the GNU GPL. + + 2. Conveying Modified Versions. + + If you modify a copy of the Library, and, in your modifications, a +facility refers to a function or data to be supplied by an Application +that uses the facility (other than as an argument passed when the +facility is invoked), then you may convey a copy of the modified +version: + + a) under this License, provided that you make a good faith effort to + ensure that, in the event an Application does not supply the + function or data, the facility still operates, and performs + whatever part of its purpose remains meaningful, or + + b) under the GNU GPL, with none of the additional permissions of + this License applicable to that copy. + + 3. Object Code Incorporating Material from Library Header Files. + + The object code form of an Application may incorporate material from +a header file that is part of the Library. You may convey such object +code under terms of your choice, provided that, if the incorporated +material is not limited to numerical parameters, data structure +layouts and accessors, or small macros, inline functions and templates +(ten or fewer lines in length), you do both of the following: + + a) Give prominent notice with each copy of the object code that the + Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the object code with a copy of the GNU GPL and this license + document. + + 4. Combined Works. + + You may convey a Combined Work under terms of your choice that, +taken together, effectively do not restrict modification of the +portions of the Library contained in the Combined Work and reverse +engineering for debugging such modifications, if you also do each of +the following: + + a) Give prominent notice with each copy of the Combined Work that + the Library is used in it and that the Library and its use are + covered by this License. + + b) Accompany the Combined Work with a copy of the GNU GPL and this license + document. + + c) For a Combined Work that displays copyright notices during + execution, include the copyright notice for the Library among + these notices, as well as a reference directing the user to the + copies of the GNU GPL and this license document. + + d) Do one of the following: + + 0) Convey the Minimal Corresponding Source under the terms of this + License, and the Corresponding Application Code in a form + suitable for, and under terms that permit, the user to + recombine or relink the Application with a modified version of + the Linked Version to produce a modified Combined Work, in the + manner specified by section 6 of the GNU GPL for conveying + Corresponding Source. + + 1) Use a suitable shared library mechanism for linking with the + Library. A suitable mechanism is one that (a) uses at run time + a copy of the Library already present on the user's computer + system, and (b) will operate properly with a modified version + of the Library that is interface-compatible with the Linked + Version. + + e) Provide Installation Information, but only if you would otherwise + be required to provide such information under section 6 of the + GNU GPL, and only to the extent that such information is + necessary to install and execute a modified version of the + Combined Work produced by recombining or relinking the + Application with a modified version of the Linked Version. (If + you use option 4d0, the Installation Information must accompany + the Minimal Corresponding Source and Corresponding Application + Code. If you use option 4d1, you must provide the Installation + Information in the manner specified by section 6 of the GNU GPL + for conveying Corresponding Source.) + + 5. Combined Libraries. + + You may place library facilities that are a work based on the +Library side by side in a single library together with other library +facilities that are not Applications and are not covered by this +License, and convey such a combined library under terms of your +choice, if you do both of the following: + + a) Accompany the combined library with a copy of the same work based + on the Library, uncombined with any other library facilities, + conveyed under the terms of this License. + + b) Give prominent notice with the combined library that part of it + is a work based on the Library, and explaining where to find the + accompanying uncombined form of the same work. + + 6. Revised Versions of the GNU Lesser General Public License. + + The Free Software Foundation may publish revised and/or new versions +of the GNU Lesser General Public License from time to time. Such new +versions will be similar in spirit to the present version, but may +differ in detail to address new problems or concerns. + + Each version is given a distinguishing version number. If the +Library as you received it specifies that a certain numbered version +of the GNU Lesser General Public License "or any later version" +applies to it, you have the option of following the terms and +conditions either of that published version or of any later version +published by the Free Software Foundation. If the Library as you +received it does not specify a version number of the GNU Lesser +General Public License, you may choose any version of the GNU Lesser +General Public License ever published by the Free Software Foundation. + + If the Library as you received it specifies that a proxy can decide +whether future versions of the GNU Lesser General Public License shall +apply, that proxy's public statement of acceptance of any version is +permanent authorization for you to choose that version for the +Library. diff --git a/MANIFEST.in.py b/MANIFEST.in.py new file mode 100644 index 0000000..b743086 --- /dev/null +++ b/MANIFEST.in.py @@ -0,0 +1,5 @@ +include LICENSE +recursive-include doc * +prune doc/_build +prune doc/generated +global-exclude .DS_Store diff --git a/README.md b/README.md index 41d7d13..6b1b5cd 100644 --- a/README.md +++ b/README.md @@ -1 +1,3 @@ xarray_extras +============= +Advanced / experimental algorithms for xarray diff --git a/ci/.coveragerc b/ci/.coveragerc new file mode 100644 index 0000000..9833b4f --- /dev/null +++ b/ci/.coveragerc @@ -0,0 +1,3 @@ +[report] +omit = + xarray_extras/tests/* diff --git a/ci/install_python.ps1 b/ci/install_python.ps1 new file mode 100644 index 0000000..63c476e --- /dev/null +++ b/ci/install_python.ps1 @@ -0,0 +1,97 @@ +# Sample script to install Python and pip under Windows +# Authors: Olivier Grisel, Jonathan Helmus and Kyle Kastner +# License: CC0 1.0 Universal: http://creativecommons.org/publicdomain/zero/1.0/ + +$MINICONDA_URL = "http://repo.continuum.io/miniconda/" +$BASE_URL = "https://www.python.org/ftp/python/" + + +function DownloadMiniconda ($python_version, $platform_suffix) { + $webclient = New-Object System.Net.WebClient + if ($python_version -match "3.6") { + $filename = "Miniconda3-latest-Windows-" + $platform_suffix + ".exe" + } else { + $filename = "Miniconda2-latest-Windows-" + $platform_suffix + ".exe" + } + $url = $MINICONDA_URL + $filename + + $basedir = $pwd.Path + "\" + $filepath = $basedir + $filename + if (Test-Path $filename) { + Write-Host "Reusing" $filepath + return $filepath + } + + # Download and retry up to 3 times in case of network transient errors. + Write-Host "Downloading" $filename "from" $url + $retry_attempts = 2 + for($i=0; $i -lt $retry_attempts; $i++){ + try { + $webclient.DownloadFile($url, $filepath) + break + } + Catch [Exception]{ + Start-Sleep 1 + } + } + if (Test-Path $filepath) { + Write-Host "File saved at" $filepath + } else { + # Retry once to get the error message if any at the last try + $webclient.DownloadFile($url, $filepath) + } + return $filepath +} + + +function InstallMiniconda ($python_version, $architecture, $python_home) { + Write-Host "Installing Python" $python_version "for" $architecture "bit architecture to" $python_home + if (Test-Path $python_home) { + Write-Host $python_home "already exists, skipping." + return $false + } + if ($architecture -match "32") { + $platform_suffix = "x86" + } else { + $platform_suffix = "x86_64" + } + + $filepath = DownloadMiniconda $python_version $platform_suffix + Write-Host "Installing" $filepath "to" $python_home + $install_log = $python_home + ".log" + $args = "/S /D=$python_home" + Write-Host $filepath $args + Start-Process -FilePath $filepath -ArgumentList $args -Wait -Passthru + if (Test-Path $python_home) { + Write-Host "Python $python_version ($architecture) installation complete" + } else { + Write-Host "Failed to install Python in $python_home" + Get-Content -Path $install_log + Exit 1 + } +} + + +function InstallCondaPackages ($python_home, $spec) { + $conda_path = $python_home + "\Scripts\conda.exe" + $args = "install --yes " + $spec + Write-Host ("conda " + $args) + Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru +} + +function UpdateConda ($python_home) { + $conda_path = $python_home + "\Scripts\conda.exe" + Write-Host "Updating conda..." + $args = "update --yes conda" + Write-Host $conda_path $args + Start-Process -FilePath "$conda_path" -ArgumentList $args -Wait -Passthru +} + + +function main () { + InstallMiniconda $env:PYTHON_VERSION $env:PYTHON_ARCH $env:PYTHON + UpdateConda $env:PYTHON + InstallCondaPackages $env:PYTHON "conda-build jinja2 anaconda-client" +} + +main diff --git a/ci/requirements-py35.yml b/ci/requirements-py35.yml new file mode 100644 index 0000000..f165bdf --- /dev/null +++ b/ci/requirements-py35.yml @@ -0,0 +1,16 @@ +name: test_env +channels: + - conda-forge +dependencies: + - python=3.5 + - dask + - pytest + - flake8 + - numba + - numpy + - pandas + - scipy + - xarray + - pip: + - coveralls + - pytest-cov diff --git a/ci/requirements-py36-nodask.yml b/ci/requirements-py36-nodask.yml new file mode 100644 index 0000000..85d9a6c --- /dev/null +++ b/ci/requirements-py36-nodask.yml @@ -0,0 +1,15 @@ +name: test_env +channels: + - conda-forge +dependencies: + - python=3.6 + - pytest + - flake8 + - numba + - numpy + - pandas + - scipy + - xarray + - pip: + - coveralls + - pytest-cov diff --git a/ci/requirements-py36-nonumba.yml b/ci/requirements-py36-nonumba.yml new file mode 100644 index 0000000..18aaba1 --- /dev/null +++ b/ci/requirements-py36-nonumba.yml @@ -0,0 +1,15 @@ +name: test_env +channels: + - conda-forge +dependencies: + - python=3.6 + - dask + - pytest + - flake8 + - numpy + - pandas + - scipy + - xarray + - pip: + - coveralls + - pytest-cov diff --git a/ci/requirements-py36.yml b/ci/requirements-py36.yml new file mode 100644 index 0000000..c751c59 --- /dev/null +++ b/ci/requirements-py36.yml @@ -0,0 +1,16 @@ +name: test_env +channels: + - conda-forge +dependencies: + - python=3.6 + - dask + - pytest + - flake8 + - numba + - numpy + - pandas + - scipy + - xarray + - pip: + - coveralls + - pytest-cov diff --git a/conftest.py b/conftest.py new file mode 100644 index 0000000..00964e4 --- /dev/null +++ b/conftest.py @@ -0,0 +1,6 @@ +"""Configuration for pytest.""" + + +def pytest_addoption(parser): + """Add command-line flags for pytest.""" + pass \ No newline at end of file diff --git a/doc/Makefile b/doc/Makefile new file mode 100644 index 0000000..d88a8a5 --- /dev/null +++ b/doc/Makefile @@ -0,0 +1,240 @@ +# Makefile for Sphinx documentation +# + +# You can set these variables from the command line. +SPHINXOPTS = +SPHINXBUILD = sphinx-build +SPHINXATUOBUILD = sphinx-autobuild +PAPER = +BUILDDIR = _build + +# Internal variables. +PAPEROPT_a4 = -D latex_paper_size=a4 +PAPEROPT_letter = -D latex_paper_size=letter +ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . +# the i18n builder cannot share the environment and doctrees with the others +I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) . + +.PHONY: help +help: + @echo "Please use \`make ' where is one of" + @echo " html to make standalone HTML files" + @echo " livehtml Make standalone HTML files and rebuild the documentation when a change is detected. Also includes a livereload enabled web server" + @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 " applehelp to make an Apple Help Book" + @echo " devhelp to make HTML files and a Devhelp project" + @echo " epub to make an epub" + @echo " epub3 to make an epub3" + @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)" + @echo " coverage to run coverage check of the documentation (if enabled)" + @echo " dummy to check syntax errors of document sources" + +.PHONY: clean +clean: + rm -rf $(BUILDDIR)/* + rm -rf generated/* + rm -rf auto_gallery/ + +.PHONY: html +html: + $(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: livehtml +livehtml: + # @echo "$(SPHINXATUOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html" + $(SPHINXATUOBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + +.PHONY: dirhtml +dirhtml: + $(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml." + +.PHONY: singlehtml +singlehtml: + $(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml + @echo + @echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml." + +.PHONY: html-noplot +html-noplot: + $(SPHINXBUILD) -D plot_gallery=0 -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html + @echo + @echo "Build finished. The HTML pages are in $(BUILDDIR)/html." + +.PHONY: pickle +pickle: + $(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle + @echo + @echo "Build finished; now you can process the pickle files." + +.PHONY: json +json: + $(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json + @echo + @echo "Build finished; now you can process the JSON files." + +.PHONY: htmlhelp +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." + +.PHONY: qthelp +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/xarray.qhcp" + @echo "To view the help file:" + @echo "# assistant -collectionFile $(BUILDDIR)/qthelp/xarray.qhc" + +.PHONY: applehelp +applehelp: + $(SPHINXBUILD) -b applehelp $(ALLSPHINXOPTS) $(BUILDDIR)/applehelp + @echo + @echo "Build finished. The help book is in $(BUILDDIR)/applehelp." + @echo "N.B. You won't be able to view it unless you put it in" \ + "~/Library/Documentation/Help or install it in your application" \ + "bundle." + +.PHONY: devhelp +devhelp: + $(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp + @echo + @echo "Build finished." + @echo "To view the help file:" + @echo "# mkdir -p $$HOME/.local/share/devhelp/xarray" + @echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/xarray" + @echo "# devhelp" + +.PHONY: epub +epub: + $(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub + @echo + @echo "Build finished. The epub file is in $(BUILDDIR)/epub." + +.PHONY: epub3 +epub3: + $(SPHINXBUILD) -b epub3 $(ALLSPHINXOPTS) $(BUILDDIR)/epub3 + @echo + @echo "Build finished. The epub3 file is in $(BUILDDIR)/epub3." + +.PHONY: latex +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)." + +.PHONY: latexpdf +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." + +.PHONY: latexpdfja +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." + +.PHONY: text +text: + $(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text + @echo + @echo "Build finished. The text files are in $(BUILDDIR)/text." + +.PHONY: man +man: + $(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man + @echo + @echo "Build finished. The manual pages are in $(BUILDDIR)/man." + +.PHONY: texinfo +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)." + +.PHONY: info +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." + +.PHONY: gettext +gettext: + $(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale + @echo + @echo "Build finished. The message catalogs are in $(BUILDDIR)/locale." + +.PHONY: changes +changes: + $(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes + @echo + @echo "The overview file is in $(BUILDDIR)/changes." + +.PHONY: linkcheck +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." + +.PHONY: doctest +doctest: + $(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest + @echo "Testing of doctests in the sources finished, look at the " \ + "results in $(BUILDDIR)/doctest/output.txt." + +.PHONY: coverage +coverage: + $(SPHINXBUILD) -b coverage $(ALLSPHINXOPTS) $(BUILDDIR)/coverage + @echo "Testing of coverage in the sources finished, look at the " \ + "results in $(BUILDDIR)/coverage/python.txt." + +.PHONY: xml +xml: + $(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml + @echo + @echo "Build finished. The XML files are in $(BUILDDIR)/xml." + +.PHONY: pseudoxml +pseudoxml: + $(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml + @echo + @echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml." + +.PHONY: dummy +dummy: + $(SPHINXBUILD) -b dummy $(ALLSPHINXOPTS) $(BUILDDIR)/dummy + @echo + @echo "Build finished. Dummy builder generates no files." diff --git a/doc/README.rst b/doc/README.rst new file mode 100644 index 0000000..0cb9fa1 --- /dev/null +++ b/doc/README.rst @@ -0,0 +1,2 @@ +xarray_extras +------ diff --git a/doc/_static/.gitignore b/doc/_static/.gitignore new file mode 100644 index 0000000..5ea6e27 --- /dev/null +++ b/doc/_static/.gitignore @@ -0,0 +1,5 @@ +examples*.png +*.log +*.pdf +*.fbd_latexmk +*.aux diff --git a/doc/_static/style.css b/doc/_static/style.css new file mode 100644 index 0000000..7257d57 --- /dev/null +++ b/doc/_static/style.css @@ -0,0 +1,18 @@ +@import url("theme.css"); + +.wy-side-nav-search>a img.logo, +.wy-side-nav-search .wy-dropdown>a img.logo { + width: 12rem +} + +.wy-side-nav-search { + background-color: #eee; +} + +.wy-side-nav-search>div.version { + display: none; +} + +.wy-nav-top { + background-color: #555; +} diff --git a/doc/_templates/layout.html b/doc/_templates/layout.html new file mode 100644 index 0000000..4c57ba8 --- /dev/null +++ b/doc/_templates/layout.html @@ -0,0 +1,2 @@ +{% extends "!layout.html" %} +{% set css_files = css_files + ["_static/style.css"] %} diff --git a/doc/api.rst b/doc/api.rst new file mode 100644 index 0000000..8fa29c1 --- /dev/null +++ b/doc/api.rst @@ -0,0 +1,17 @@ +.. currentmodule:: xarray + +############# +API reference +############# + +This page provides an auto-generated summary of xarray_extras's API. For more details +and examples, refer to the relevant chapters in the main part of the +documentation. + +Top-level functions +=================== + +.. autosummary:: + :toctree: generated/ + + diff --git a/doc/conf.py b/doc/conf.py new file mode 100644 index 0000000..8ad35f3 --- /dev/null +++ b/doc/conf.py @@ -0,0 +1,318 @@ +# -*- coding: utf-8 -*- +# +# xarray_extras documentation build configuration file, created by +# sphinx-quickstart on Thu Feb 6 18:57:54 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 datetime +import importlib +import os +import sys + +import xarray_extras + +allowed_failures = set() + +print("python exec:", sys.executable) +print("sys.path:", sys.path) +for name in ('numpy numba scipy pandas dask xarray').split(): + try: + module = importlib.import_module(name) + fname = module.__file__.rstrip('__init__.py') + print("%s: %s, %s" % (name, module.__version__, fname)) + except ImportError: + print("no %s" % name) + +print("xarray_extras: %s, %s" % (xarray_extras.__version__, xarray_extras.__file__)) + +# -- General configuration ------------------------------------------------ + +# If your documentation needs a minimal Sphinx version, state it here. +#needs_sphinx = '1.0' + +# Add any Sphinx extension module names here, as strings. They can be +# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom +# ones. +extensions = [ + 'sphinx.ext.autodoc', + 'sphinx.ext.autosummary', + 'sphinx.ext.intersphinx', + 'sphinx.ext.extlinks', + 'sphinx.ext.mathjax', + 'numpydoc', + 'IPython.sphinxext.ipython_directive', + 'IPython.sphinxext.ipython_console_highlighting', + 'sphinx_gallery.gen_gallery', +] + +extlinks = {'issue': ('https://github.com/crusaderky/xarray_extras/issues/%s', 'GH'), + 'pull': ('https://github.com/crusaderky/xarray_extras/pull/%s', 'PR'), + } + +sphinx_gallery_conf = {'examples_dirs': 'gallery', + 'gallery_dirs': 'auto_gallery', + 'backreferences_dir': False, + 'expected_failing_examples': list(allowed_failures) + } + +autosummary_generate = True + +numpydoc_class_members_toctree = True +numpydoc_show_class_members = False + +# 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 = 'xarray_extras' +copyright = '2018-%s, xarray_extras Developers' % datetime.datetime.now().year + +# 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. +# +# The short X.Y version. +version = xarray_extras.version.short_version +# The full version, including alpha/beta/rc tags. +release = xarray_extras.__version__ + +# 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 = '' +# Else, today_fmt is used as the format for a strftime call. +today_fmt = '%Y-%m-%d' + +# 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 = [] + +# If true, keep warnings as "system message" paragraphs in the built documents. +#keep_warnings = False + + +# -- Options for HTML output ---------------------------------------------- + +# The theme to use for HTML and HTML Help pages. See the documentation for +# a list of builtin themes. +html_theme = 'sphinx_rtd_theme' + +# 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 = { + 'logo_only': 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 = "_static/dataset-diagram-logo.png" + +# 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'] + +# Sometimes the savefig directory doesn't exist and needs to be created +# https://github.com/ipython/ipython/issues/8733 +# becomes obsolete when we can pin ipython>=5.2; see doc/environment.yml +ipython_savefig_dir = os.path.join(os.path.dirname(os.path.abspath(__file__)), + '_build','html','_static') +if not os.path.exists(ipython_savefig_dir): + os.makedirs(ipython_savefig_dir) + +# 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 = today_fmt + +# 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 = 'xarray_extrasdoc' + + +# -- 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', 'xarray_extras.tex', 'xarray_extras Documentation', + 'xarray_extras Developers', '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', 'xarray_extras', 'xarray_extras Documentation', + ['xarray_extras Developers'], 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', 'xarray_extras', 'xarray_extras Documentation', + 'xarray_extras Developers', 'xarray_extras', + 'Advanced / experimental algorithms for xarray', + '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 = { + 'python': ('https://docs.python.org/3/', None), + 'dask': ('https://dask.pydata.org/', None), + 'pandas': ('https://pandas.pydata.org/pandas-docs/stable/', None), + 'numpy': ('https://docs.scipy.org/doc/numpy/', None), + 'numba': ('https://numba.pydata.org/numba-doc/latest/', None), + 'scipy': ('https://docs.scipy.org/doc/scipy/', None), + 'xarray': ('https://xarray.pydata.org/', None), +} diff --git a/doc/environment.yml b/doc/environment.yml new file mode 100644 index 0000000..24765a1 --- /dev/null +++ b/doc/environment.yml @@ -0,0 +1,15 @@ +name: xarray-docs +channels: + - conda-forge + - defaults +dependencies: + - python=3.6 + - numpy=1.13 + - pandas=0.21.0 + - scipy=1.0 + - numpydoc=0.7.0 + - dask=0.16.0 + - sphinx=1.5 + - sphinx-gallery + - flake8 + - xarray diff --git a/doc/index.rst b/doc/index.rst new file mode 100644 index 0000000..8b0bc5a --- /dev/null +++ b/doc/index.rst @@ -0,0 +1,16 @@ +xarray_extras: Advanced algorithms for xarray +============================================= + +Documentation +------------- + +* :doc:`api` +* :doc:`installing` +* :doc:`whats-new` + +License +------- + +xarray_extras is available under the open source `LGPL License`__. + +__ https://www.gnu.org/licenses/lgpl-3.0.en.html diff --git a/doc/installing.rst b/doc/installing.rst new file mode 100644 index 0000000..3488267 --- /dev/null +++ b/doc/installing.rst @@ -0,0 +1,27 @@ +.. _installing: + +Installation +============ + +Required dependencies +--------------------- + +- Python 3.5 or 3.6 +- `xarray `__ +- `scipy `__ + +Optional dependencies +--------------------- +- `dask `__ +- `numba `__ + +Testing +------- + +To run the test suite after installing xarray_extras, first install (via pypi or conda) + +- `py.test `__: Simple unit testing library + +and run +``py.test --pyargs xarray_extras``. + diff --git a/doc/whats-new.rst b/doc/whats-new.rst new file mode 100644 index 0000000..9fe9ab3 --- /dev/null +++ b/doc/whats-new.rst @@ -0,0 +1,19 @@ +.. currentmodule:: xarray + +What's New +========== + +.. ipython:: python + :suppress: + + import numpy as np + import pandas as pd + import xarray + np.random.seed(123456) + +.. _whats-new.0.1.0: + +v0.1.0 (unreleased) +------------------- + +Initial release. \ No newline at end of file diff --git a/readthedocs.yml b/readthedocs.yml new file mode 100644 index 0000000..0129abe --- /dev/null +++ b/readthedocs.yml @@ -0,0 +1,5 @@ +conda: + file: doc/environment.yml +python: + version: 3 + setup_py_install: true diff --git a/setup.cfg b/setup.cfg new file mode 100644 index 0000000..381569c --- /dev/null +++ b/setup.cfg @@ -0,0 +1,17 @@ +[wheel] +universal = 1 + +[tool:pytest] +python_files=test_*.py +testpaths=xarray_extras/tests + +[flake8] +max-line-length=79 +ignore= +exclude= + doc/ + +[isort] +default_section=THIRDPARTY +known_first_party=xarray_extras +multi_line_output=4 diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..0f05c9f --- /dev/null +++ b/setup.py @@ -0,0 +1,126 @@ +#!/usr/bin/env python +import os +import re +import warnings + +from setuptools import find_packages, setup + +MAJOR = 0 +MINOR = 1 +MICRO = 0 +ISRELEASED = False +VERSION = '%d.%d.%d' % (MAJOR, MINOR, MICRO) +QUALIFIER = '' + + +DISTNAME = 'xarray_extras' +LICENSE = 'LGPL' +AUTHOR = 'Guido Imperiale' +AUTHOR_EMAIL = 'guido.imperiale@gmail.com' +URL = 'https://github.com/crusaderky/xarray_extras' +CLASSIFIERS = [ + 'Development Status :: 3 - Alpha', + 'License :: OSI Approved :: LGPL v3', + 'Operating System :: OS Independent', + 'Intended Audience :: Science/Research', + 'Programming Language :: Python', + 'Programming Language :: Python :: 3', + 'Programming Language :: Python :: 3.5', + 'Programming Language :: Python :: 3.6', + 'Topic :: Scientific/Engineering', +] + +INSTALL_REQUIRES = ['numpy >= 1.11', 'pandas >= 0.18.0', 'xarray >= 0.10.3'] +TESTS_REQUIRE = ['pytest >= 2.7.1'] + +DESCRIPTION = "Advanced / experimental algorithms for xarray" +LONG_DESCRIPTION = """ + +""" # noqa + +# Code to extract and write the version copied from pandas. +# Used under the terms of pandas's license, see licenses/PANDAS_LICENSE. +FULLVERSION = VERSION +write_version = True + +if not ISRELEASED: + import subprocess + FULLVERSION += '.dev' + + pipe = None + for cmd in ['git', 'git.cmd']: + try: + pipe = subprocess.Popen( + [cmd, "describe", "--always", "--match", "v[0-9]*"], + stdout=subprocess.PIPE) + (so, serr) = pipe.communicate() + if pipe.returncode == 0: + break + except BaseException: + pass + + if pipe is None or pipe.returncode != 0: + # no git, or not in git dir + if os.path.exists('xarray_extras/version.py'): + warnings.warn( + "WARNING: Couldn't get git revision," + " using existing xarray_extras/version.py") + write_version = False + else: + warnings.warn( + "WARNING: Couldn't get git revision," + " using generic version string") + else: + # have git, in git dir, but may have used a shallow clone (travis does + # this) + rev = so.strip() + rev = rev.decode('ascii') + + if not rev.startswith('v') and re.match("[a-zA-Z0-9]{7,9}", rev): + # partial clone, manually construct version string + # this is the format before we started using git-describe + # to get an ordering on dev version strings. + rev = "v%s+dev.%s" % (VERSION, rev) + + # Strip leading v from tags format "vx.y.z" to get th version string + FULLVERSION = rev.lstrip('v') + + # make sure we respect PEP 440 + FULLVERSION = FULLVERSION.replace("-", "+dev", 1).replace("-", ".") + +else: + FULLVERSION += QUALIFIER + + +def write_version_py(filename=None): + cnt = """\ +version = '%s' +short_version = '%s' +""" + if not filename: + filename = os.path.join( + os.path.dirname(__file__), 'xarray_extras', 'version.py') + + a = open(filename, 'w') + try: + a.write(cnt % (FULLVERSION, VERSION)) + finally: + a.close() + + +if write_version: + write_version_py() + +setup(name=DISTNAME, + version=FULLVERSION, + license=LICENSE, + author=AUTHOR, + author_email=AUTHOR_EMAIL, + classifiers=CLASSIFIERS, + description=DESCRIPTION, + long_description=LONG_DESCRIPTION, + install_requires=INSTALL_REQUIRES, + tests_require=TESTS_REQUIRE, + url=URL, + packages=find_packages(), + package_data={'xarray_extras': ['tests/data/*']}) diff --git a/xarray_extras/__init__.py b/xarray_extras/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/xarray_extras/tests/__init__.py b/xarray_extras/tests/__init__.py new file mode 100644 index 0000000..e69de29