Initial commit
This commit is contained in:
commit
84925dc8b5
43
.github/workflows/ci.yml
vendored
Normal file
43
.github/workflows/ci.yml
vendored
Normal file
@ -0,0 +1,43 @@
|
||||
name: ci
|
||||
|
||||
# Controls when the workflow will run
|
||||
on:
|
||||
|
||||
# Trigger the workflow on all pushes
|
||||
push:
|
||||
branches:
|
||||
- '**'
|
||||
tags:
|
||||
- '**'
|
||||
|
||||
# Trigger the workflow on all pull requests
|
||||
pull_request: ~
|
||||
|
||||
# Trigger the workflow on release creation
|
||||
release:
|
||||
types:
|
||||
- created
|
||||
|
||||
# Allow workflow to be dispatched on demand
|
||||
workflow_dispatch: ~
|
||||
|
||||
jobs:
|
||||
|
||||
# Calls a reusable CI workflow to qa, test & deploy the current repository.
|
||||
# We skip jobs that will result in duplicate jobs, since the code does not depend on the compiler.
|
||||
# It will produce a code coverage report on success and upload it to the codecov service.
|
||||
# If all checks were successful and a new release tag created, the package will be published on PyPI.
|
||||
ci:
|
||||
name: ci
|
||||
uses: ecmwf-actions/reusable-workflows/.github/workflows/ci-python.yml@v1
|
||||
with:
|
||||
# codecov_upload: true
|
||||
skip_matrix_jobs: |
|
||||
clang-12@ubuntu-20.04
|
||||
clang-9@ubuntu-18.04
|
||||
clang-12@macos-10.15
|
||||
build_package_inputs: |
|
||||
self_build: false
|
||||
secrets:
|
||||
pypi_username: ${{ secrets.PYPI_USERNAME }}
|
||||
pypi_password: ${{ secrets.PYPI_PASSWORD }}
|
129
.gitignore
vendored
Normal file
129
.gitignore
vendored
Normal file
@ -0,0 +1,129 @@
|
||||
# Byte-compiled / optimized / DLL files
|
||||
__pycache__/
|
||||
*.py[cod]
|
||||
*$py.class
|
||||
|
||||
# C extensions
|
||||
*.so
|
||||
|
||||
# Distribution / packaging
|
||||
.Python
|
||||
build/
|
||||
develop-eggs/
|
||||
dist/
|
||||
downloads/
|
||||
eggs/
|
||||
.eggs/
|
||||
lib/
|
||||
lib64/
|
||||
parts/
|
||||
sdist/
|
||||
var/
|
||||
wheels/
|
||||
pip-wheel-metadata/
|
||||
share/python-wheels/
|
||||
*.egg-info/
|
||||
.installed.cfg
|
||||
*.egg
|
||||
MANIFEST
|
||||
|
||||
# PyInstaller
|
||||
# Usually these files are written by a python script from a template
|
||||
# before PyInstaller builds the exe, so as to inject date/other infos into it.
|
||||
*.manifest
|
||||
*.spec
|
||||
|
||||
# Installer logs
|
||||
pip-log.txt
|
||||
pip-delete-this-directory.txt
|
||||
|
||||
# Unit test / coverage reports
|
||||
htmlcov/
|
||||
.tox/
|
||||
.nox/
|
||||
.coverage
|
||||
.coverage.*
|
||||
.cache
|
||||
nosetests.xml
|
||||
coverage.xml
|
||||
*.cover
|
||||
*.py,cover
|
||||
.hypothesis/
|
||||
.pytest_cache/
|
||||
|
||||
# Translations
|
||||
*.mo
|
||||
*.pot
|
||||
|
||||
# Django stuff:
|
||||
*.log
|
||||
local_settings.py
|
||||
db.sqlite3
|
||||
db.sqlite3-journal
|
||||
|
||||
# Flask stuff:
|
||||
instance/
|
||||
.webassets-cache
|
||||
|
||||
# Scrapy stuff:
|
||||
.scrapy
|
||||
|
||||
# Sphinx documentation
|
||||
docs/_build/
|
||||
|
||||
# PyBuilder
|
||||
target/
|
||||
|
||||
# Jupyter Notebook
|
||||
.ipynb_checkpoints
|
||||
|
||||
# IPython
|
||||
profile_default/
|
||||
ipython_config.py
|
||||
|
||||
# pyenv
|
||||
.python-version
|
||||
|
||||
# pipenv
|
||||
# According to pypa/pipenv#598, it is recommended to include Pipfile.lock in version control.
|
||||
# However, in case of collaboration, if having platform-specific dependencies or dependencies
|
||||
# having no cross-platform support, pipenv may install dependencies that don't work, or not
|
||||
# install all needed dependencies.
|
||||
#Pipfile.lock
|
||||
|
||||
# PEP 582; used by e.g. github.com/David-OConnor/pyflow
|
||||
__pypackages__/
|
||||
|
||||
# Celery stuff
|
||||
celerybeat-schedule
|
||||
celerybeat.pid
|
||||
|
||||
# SageMath parsed files
|
||||
*.sage.py
|
||||
|
||||
# Environments
|
||||
.env
|
||||
.venv
|
||||
env/
|
||||
venv/
|
||||
ENV/
|
||||
env.bak/
|
||||
venv.bak/
|
||||
|
||||
# Spyder project settings
|
||||
.spyderproject
|
||||
.spyproject
|
||||
|
||||
# Rope project settings
|
||||
.ropeproject
|
||||
|
||||
# mkdocs documentation
|
||||
/site
|
||||
|
||||
# mypy
|
||||
.mypy_cache/
|
||||
.dmypy.json
|
||||
dmypy.json
|
||||
|
||||
# Pyre type checker
|
||||
.pyre/
|
201
LICENSE
Normal file
201
LICENSE
Normal file
@ -0,0 +1,201 @@
|
||||
Apache License
|
||||
Version 2.0, January 2004
|
||||
http://www.apache.org/licenses/
|
||||
|
||||
TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION
|
||||
|
||||
1. Definitions.
|
||||
|
||||
"License" shall mean the terms and conditions for use, reproduction,
|
||||
and distribution as defined by Sections 1 through 9 of this document.
|
||||
|
||||
"Licensor" shall mean the copyright owner or entity authorized by
|
||||
the copyright owner that is granting the License.
|
||||
|
||||
"Legal Entity" shall mean the union of the acting entity and all
|
||||
other entities that control, are controlled by, or are under common
|
||||
control with that entity. For the purposes of this definition,
|
||||
"control" means (i) the power, direct or indirect, to cause the
|
||||
direction or management of such entity, whether by contract or
|
||||
otherwise, or (ii) ownership of fifty percent (50%) or more of the
|
||||
outstanding shares, or (iii) beneficial ownership of such entity.
|
||||
|
||||
"You" (or "Your") shall mean an individual or Legal Entity
|
||||
exercising permissions granted by this License.
|
||||
|
||||
"Source" form shall mean the preferred form for making modifications,
|
||||
including but not limited to software source code, documentation
|
||||
source, and configuration files.
|
||||
|
||||
"Object" form shall mean any form resulting from mechanical
|
||||
transformation or translation of a Source form, including but
|
||||
not limited to compiled object code, generated documentation,
|
||||
and conversions to other media types.
|
||||
|
||||
"Work" shall mean the work of authorship, whether in Source or
|
||||
Object form, made available under the License, as indicated by a
|
||||
copyright notice that is included in or attached to the work
|
||||
(an example is provided in the Appendix below).
|
||||
|
||||
"Derivative Works" shall mean any work, whether in Source or Object
|
||||
form, that is based on (or derived from) the Work and for which the
|
||||
editorial revisions, annotations, elaborations, or other modifications
|
||||
represent, as a whole, an original work of authorship. For the purposes
|
||||
of this License, Derivative Works shall not include works that remain
|
||||
separable from, or merely link (or bind by name) to the interfaces of,
|
||||
the Work and Derivative Works thereof.
|
||||
|
||||
"Contribution" shall mean any work of authorship, including
|
||||
the original version of the Work and any modifications or additions
|
||||
to that Work or Derivative Works thereof, that is intentionally
|
||||
submitted to Licensor for inclusion in the Work by the copyright owner
|
||||
or by an individual or Legal Entity authorized to submit on behalf of
|
||||
the copyright owner. For the purposes of this definition, "submitted"
|
||||
means any form of electronic, verbal, or written communication sent
|
||||
to the Licensor or its representatives, including but not limited to
|
||||
communication on electronic mailing lists, source code control systems,
|
||||
and issue tracking systems that are managed by, or on behalf of, the
|
||||
Licensor for the purpose of discussing and improving the Work, but
|
||||
excluding communication that is conspicuously marked or otherwise
|
||||
designated in writing by the copyright owner as "Not a Contribution."
|
||||
|
||||
"Contributor" shall mean Licensor and any individual or Legal Entity
|
||||
on behalf of whom a Contribution has been received by Licensor and
|
||||
subsequently incorporated within the Work.
|
||||
|
||||
2. Grant of Copyright License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
copyright license to reproduce, prepare Derivative Works of,
|
||||
publicly display, publicly perform, sublicense, and distribute the
|
||||
Work and such Derivative Works in Source or Object form.
|
||||
|
||||
3. Grant of Patent License. Subject to the terms and conditions of
|
||||
this License, each Contributor hereby grants to You a perpetual,
|
||||
worldwide, non-exclusive, no-charge, royalty-free, irrevocable
|
||||
(except as stated in this section) patent license to make, have made,
|
||||
use, offer to sell, sell, import, and otherwise transfer the Work,
|
||||
where such license applies only to those patent claims licensable
|
||||
by such Contributor that are necessarily infringed by their
|
||||
Contribution(s) alone or by combination of their Contribution(s)
|
||||
with the Work to which such Contribution(s) was submitted. If You
|
||||
institute patent litigation against any entity (including a
|
||||
cross-claim or counterclaim in a lawsuit) alleging that the Work
|
||||
or a Contribution incorporated within the Work constitutes direct
|
||||
or contributory patent infringement, then any patent licenses
|
||||
granted to You under this License for that Work shall terminate
|
||||
as of the date such litigation is filed.
|
||||
|
||||
4. Redistribution. You may reproduce and distribute copies of the
|
||||
Work or Derivative Works thereof in any medium, with or without
|
||||
modifications, and in Source or Object form, provided that You
|
||||
meet the following conditions:
|
||||
|
||||
(a) You must give any other recipients of the Work or
|
||||
Derivative Works a copy of this License; and
|
||||
|
||||
(b) You must cause any modified files to carry prominent notices
|
||||
stating that You changed the files; and
|
||||
|
||||
(c) You must retain, in the Source form of any Derivative Works
|
||||
that You distribute, all copyright, patent, trademark, and
|
||||
attribution notices from the Source form of the Work,
|
||||
excluding those notices that do not pertain to any part of
|
||||
the Derivative Works; and
|
||||
|
||||
(d) If the Work includes a "NOTICE" text file as part of its
|
||||
distribution, then any Derivative Works that You distribute must
|
||||
include a readable copy of the attribution notices contained
|
||||
within such NOTICE file, excluding those notices that do not
|
||||
pertain to any part of the Derivative Works, in at least one
|
||||
of the following places: within a NOTICE text file distributed
|
||||
as part of the Derivative Works; within the Source form or
|
||||
documentation, if provided along with the Derivative Works; or,
|
||||
within a display generated by the Derivative Works, if and
|
||||
wherever such third-party notices normally appear. The contents
|
||||
of the NOTICE file are for informational purposes only and
|
||||
do not modify the License. You may add Your own attribution
|
||||
notices within Derivative Works that You distribute, alongside
|
||||
or as an addendum to the NOTICE text from the Work, provided
|
||||
that such additional attribution notices cannot be construed
|
||||
as modifying the License.
|
||||
|
||||
You may add Your own copyright statement to Your modifications and
|
||||
may provide additional or different license terms and conditions
|
||||
for use, reproduction, or distribution of Your modifications, or
|
||||
for any such Derivative Works as a whole, provided Your use,
|
||||
reproduction, and distribution of the Work otherwise complies with
|
||||
the conditions stated in this License.
|
||||
|
||||
5. Submission of Contributions. Unless You explicitly state otherwise,
|
||||
any Contribution intentionally submitted for inclusion in the Work
|
||||
by You to the Licensor shall be under the terms and conditions of
|
||||
this License, without any additional terms or conditions.
|
||||
Notwithstanding the above, nothing herein shall supersede or modify
|
||||
the terms of any separate license agreement you may have executed
|
||||
with Licensor regarding such Contributions.
|
||||
|
||||
6. Trademarks. This License does not grant permission to use the trade
|
||||
names, trademarks, service marks, or product names of the Licensor,
|
||||
except as required for reasonable and customary use in describing the
|
||||
origin of the Work and reproducing the content of the NOTICE file.
|
||||
|
||||
7. Disclaimer of Warranty. Unless required by applicable law or
|
||||
agreed to in writing, Licensor provides the Work (and each
|
||||
Contributor provides its Contributions) on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or
|
||||
implied, including, without limitation, any warranties or conditions
|
||||
of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A
|
||||
PARTICULAR PURPOSE. You are solely responsible for determining the
|
||||
appropriateness of using or redistributing the Work and assume any
|
||||
risks associated with Your exercise of permissions under this License.
|
||||
|
||||
8. Limitation of Liability. In no event and under no legal theory,
|
||||
whether in tort (including negligence), contract, or otherwise,
|
||||
unless required by applicable law (such as deliberate and grossly
|
||||
negligent acts) or agreed to in writing, shall any Contributor be
|
||||
liable to You for damages, including any direct, indirect, special,
|
||||
incidental, or consequential damages of any character arising as a
|
||||
result of this License or out of the use or inability to use the
|
||||
Work (including but not limited to damages for loss of goodwill,
|
||||
work stoppage, computer failure or malfunction, or any and all
|
||||
other commercial damages or losses), even if such Contributor
|
||||
has been advised of the possibility of such damages.
|
||||
|
||||
9. Accepting Warranty or Additional Liability. While redistributing
|
||||
the Work or Derivative Works thereof, You may choose to offer,
|
||||
and charge a fee for, acceptance of support, warranty, indemnity,
|
||||
or other liability obligations and/or rights consistent with this
|
||||
License. However, in accepting such obligations, You may act only
|
||||
on Your own behalf and on Your sole responsibility, not on behalf
|
||||
of any other Contributor, and only if You agree to indemnify,
|
||||
defend, and hold each Contributor harmless for any liability
|
||||
incurred by, or claims asserted against, such Contributor by reason
|
||||
of your accepting any such warranty or additional liability.
|
||||
|
||||
END OF TERMS AND CONDITIONS
|
||||
|
||||
APPENDIX: How to apply the Apache License to your work.
|
||||
|
||||
To apply the Apache License to your work, attach the following
|
||||
boilerplate notice, with the fields enclosed by brackets "[]"
|
||||
replaced with your own identifying information. (Don't include
|
||||
the brackets!) The text should be enclosed in the appropriate
|
||||
comment syntax for the file format. We also recommend that a
|
||||
file or class name and description of purpose be included on the
|
||||
same "printed page" as the copyright notice for easier
|
||||
identification within third-party archives.
|
||||
|
||||
Copyright [yyyy] [name of copyright owner]
|
||||
|
||||
Licensed under the Apache License, Version 2.0 (the "License");
|
||||
you may not use this file except in compliance with the License.
|
||||
You may obtain a copy of the License at
|
||||
|
||||
http://www.apache.org/licenses/LICENSE-2.0
|
||||
|
||||
Unless required by applicable law or agreed to in writing, software
|
||||
distributed under the License is distributed on an "AS IS" BASIS,
|
||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||
See the License for the specific language governing permissions and
|
||||
limitations under the License.
|
9
PACKAGE_NAME/__init__.py
Normal file
9
PACKAGE_NAME/__init__.py
Normal file
@ -0,0 +1,9 @@
|
||||
# (C) Copyright 1996- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||
# granted to it by virtue of its status as an intergovernmental organisation
|
||||
# nor does it submit to any jurisdiction.
|
||||
|
||||
from .__meta__ import * # noqa
|
16
PACKAGE_NAME/__meta__.py
Normal file
16
PACKAGE_NAME/__meta__.py
Normal file
@ -0,0 +1,16 @@
|
||||
# (C) Copyright 1996- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||
# granted to it by virtue of its status as an intergovernmental organisation
|
||||
# nor does it submit to any jurisdiction.
|
||||
|
||||
"""Container for project metadata."""
|
||||
|
||||
__name__ = "PACKAGE_NAME"
|
||||
__version__ = "0.1.dev0"
|
||||
__author__ = "European Centre for Medium-Range Weather Forecasts (ECMWF)"
|
||||
__author_email__ = "software.support@ecmwf.int"
|
||||
__license__ = "Apache License Version 2.0"
|
||||
__description__ = ""
|
34
PACKAGE_NAME/sample.py
Normal file
34
PACKAGE_NAME/sample.py
Normal file
@ -0,0 +1,34 @@
|
||||
# (C) Copyright 1996- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||
# granted to it by virtue of its status as an intergovernmental organisation
|
||||
# nor does it submit to any jurisdiction.
|
||||
|
||||
"""
|
||||
SAMPLE MODULE - demonstrates basic code style.
|
||||
"""
|
||||
|
||||
import numpy as np
|
||||
|
||||
|
||||
def speed_direction_to_uv(speed, direction):
|
||||
"""
|
||||
Calculate wind u- and v-components from wind speed and direction.
|
||||
|
||||
Parameters
|
||||
----------
|
||||
speed : array
|
||||
Array containing value(s) of wind speed.
|
||||
wind_v : array
|
||||
Array containing values of wind (from) direction, in degrees.
|
||||
|
||||
Returns
|
||||
-------
|
||||
tuple
|
||||
Tuple containing arrays of wind u- and v-components.
|
||||
"""
|
||||
wind_u = speed * np.cos(np.deg2rad(direction))
|
||||
wind_v = speed * np.sin(np.deg2rad(direction))
|
||||
return wind_u, wind_v
|
90
README.rst
Normal file
90
README.rst
Normal file
@ -0,0 +1,90 @@
|
||||
|
||||
****************************
|
||||
python-package-template-repo
|
||||
****************************
|
||||
|
||||
|license| |tag_release| |commits_since_release| |last_commit|
|
||||
|
||||
A template repository for developing Python packages under `ecmwf-projects <https://github.com/ecmwf-projects>`_.
|
||||
|
||||
**Quick start**
|
||||
|
||||
Follow these steps to create a new repository from this template.
|
||||
|
||||
#. Click the `Use this template <https://github.com/ecmwf-projects/python-package-template-repo/generate>`_
|
||||
button and create a new repository with your desired name, location and visibility.
|
||||
|
||||
#. Clone the repository::
|
||||
|
||||
git clone git@github.com:ecmwf-projects/<your-repository-name>.git
|
||||
cd <your-repository-name>
|
||||
|
||||
#. Remove sample code::
|
||||
|
||||
rm PACKAGE_NAME/sample.py
|
||||
rm tests/test_sample.py
|
||||
|
||||
#. Replace ``PACKAGE_NAME`` with your chosen package name::
|
||||
|
||||
NEW_PACKAGE_NAME=<your-package-name>
|
||||
mv PACKAGE_NAME $NEW_PACKAGE_NAME
|
||||
sed -i "" "s/PACKAGE_NAME/$NEW_PACKAGE_NAME/g" setup.py \
|
||||
docs/source/conf.py \
|
||||
docs/source/getting_started/installing.rst \
|
||||
docs/source/index.rst \
|
||||
$NEW_PACKAGE_NAME/__meta__.py
|
||||
|
||||
#. Modify the contents of ``__meta__.py`` to reflect your repository. Note that there
|
||||
is no need to update this same information in ``setup.py``, as it will be imported
|
||||
directly from ``__meta__.py``.
|
||||
|
||||
#. Modify the project url in ``setup.py`` to reflect your project's home in GitHub.
|
||||
|
||||
#. Modify ``README.rst`` to reflect your repository. A number of `shield <https://shields.io/>`_
|
||||
templates are included, and will need to be updated to match your repository if you want
|
||||
to use them.
|
||||
|
||||
**Usage tips**
|
||||
|
||||
* Create an executable called ``qa`` containing the following::
|
||||
|
||||
black .
|
||||
isort .
|
||||
|
||||
Add this to your path, and run it from the top-level of your repository before
|
||||
committing changes::
|
||||
|
||||
qa .
|
||||
|
||||
.. |last_commit| image:: https://img.shields.io/github/last-commit/ecmwf-projects/thermofeel
|
||||
:target: https://github.com/ecmwf-projects/thermofeel
|
||||
|
||||
.. |commits_since_release| image:: https://img.shields.io/github/commits-since/ecmwf-projects/thermofeel/latest?sort=semver
|
||||
:target: https://github.com/ecmwf-projects/thermofeel
|
||||
|
||||
.. |license| image:: https://img.shields.io/github/license/ecmwf-projects/thermofeel
|
||||
:target: https://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
.. |pypi_release| image:: https://img.shields.io/pypi/v/thermofeel?color=green
|
||||
:target: https://pypi.org/project/thermofeel
|
||||
|
||||
.. |pypi_status| image:: https://img.shields.io/pypi/status/thermofeel
|
||||
:target: https://pypi.org/project/thermofeel
|
||||
|
||||
.. |tag_release| image:: https://img.shields.io/github/v/release/ecmwf-projects/thermofeel?sort=semver
|
||||
:target: https://github.com/ecmwf-projects/thermofeel
|
||||
|
||||
.. |codecov| image:: https://codecov.io/gh/ecmwf-projects/thermofeel/branch/master/graph/badge.svg
|
||||
:target: https://codecov.io/gh/ecmwf-projects/thermofeel
|
||||
|
||||
.. |ci| image:: https://img.shields.io/github/workflow/status/ecmwf-projects/thermofeel/ci
|
||||
:target: https://github.com/ecmwf-projects/thermofeel/actions
|
||||
|
||||
.. |pypi_downloads| image:: https://img.shields.io/pypi/dm/thermofeel
|
||||
:target: https://pypi.org/project/thermofeel
|
||||
|
||||
.. |code_size| image:: https://img.shields.io/github/languages/code-size/ecmwf-projects/thermofeel?color=green
|
||||
:target: https://github.com/ecmwf-projects/thermofeel
|
||||
|
||||
.. |docs| image:: https://readthedocs.org/projects/thermofeel/badge/?version=latest
|
||||
:target: https://thermofeel.readthedocs.io/en/latest/?badge=latest
|
20
docs/Makefile
Normal file
20
docs/Makefile
Normal file
@ -0,0 +1,20 @@
|
||||
# Minimal makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line, and also
|
||||
# from the environment for the first two.
|
||||
SPHINXOPTS ?=
|
||||
SPHINXBUILD ?= sphinx-build
|
||||
SOURCEDIR = source
|
||||
BUILDDIR = build
|
||||
|
||||
# Put it first so that "make" without argument is like "make help".
|
||||
help:
|
||||
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
||||
|
||||
.PHONY: help Makefile
|
||||
|
||||
# Catch-all target: route all unknown targets to Sphinx using the new
|
||||
# "make mode" option. $(O) is meant as a shortcut for $(SPHINXOPTS).
|
||||
%: Makefile
|
||||
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
44
docs/README.rst
Normal file
44
docs/README.rst
Normal file
@ -0,0 +1,44 @@
|
||||
|
||||
****************************
|
||||
python-package-template-repo
|
||||
****************************
|
||||
|
||||
A template documentation tree for creating readthedocs compatible documentation.
|
||||
|
||||
**Quick start**
|
||||
|
||||
Follow these steps to prepare your documentation for readthedocs.
|
||||
|
||||
#. Install requirements
|
||||
|
||||
pip3 install -r requirements.txt
|
||||
|
||||
#. Create the supporting rst files and add them to the source directory, you should remove any
|
||||
existing rst files to ensure a clean build:
|
||||
|
||||
rm source/reference/*rst
|
||||
sphinx-apidoc -o source/reference -H "API reference" --tocfile api -f ../PACKAGE_NAME/
|
||||
|
||||
#. Update the source/index.rst to reference the rst files create above. Depending on the contents of your package and the
|
||||
rst files produced you will need to add something like the following to the Reference section:
|
||||
|
||||
* :doc:`modules`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
:caption: Reference
|
||||
|
||||
modules
|
||||
|
||||
|
||||
These steps will allow readthedocs to construct your documentation pages. It is possible to build the html pages locally
|
||||
for testing. From the `docs/source` directory execute the following:
|
||||
|
||||
make html
|
||||
open build/html/index.html # To open with your default html application
|
||||
|
||||
|
||||
|
||||
|
||||
|
35
docs/make.bat
Normal file
35
docs/make.bat
Normal file
@ -0,0 +1,35 @@
|
||||
@ECHO OFF
|
||||
|
||||
pushd %~dp0
|
||||
|
||||
REM Command file for Sphinx documentation
|
||||
|
||||
if "%SPHINXBUILD%" == "" (
|
||||
set SPHINXBUILD=sphinx-build
|
||||
)
|
||||
set SOURCEDIR=source
|
||||
set BUILDDIR=build
|
||||
|
||||
if "%1" == "" goto help
|
||||
|
||||
%SPHINXBUILD% >NUL 2>NUL
|
||||
if errorlevel 9009 (
|
||||
echo.
|
||||
echo.The 'sphinx-build' command was not found. Make sure you have Sphinx
|
||||
echo.installed, then set the SPHINXBUILD environment variable to point
|
||||
echo.to the full path of the 'sphinx-build' executable. Alternatively you
|
||||
echo.may add the Sphinx directory to PATH.
|
||||
echo.
|
||||
echo.If you don't have Sphinx installed, grab it from
|
||||
echo.http://sphinx-doc.org/
|
||||
exit /b 1
|
||||
)
|
||||
|
||||
%SPHINXBUILD% -M %1 %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
goto end
|
||||
|
||||
:help
|
||||
%SPHINXBUILD% -M help %SOURCEDIR% %BUILDDIR% %SPHINXOPTS% %O%
|
||||
|
||||
:end
|
||||
popd
|
5
docs/requirements.txt
Normal file
5
docs/requirements.txt
Normal file
@ -0,0 +1,5 @@
|
||||
# Requirements for readthedocs
|
||||
sphinx
|
||||
ipykernel
|
||||
nbsphinx
|
||||
sphinx_rtd_theme
|
57
docs/source/conf.py
Normal file
57
docs/source/conf.py
Normal file
@ -0,0 +1,57 @@
|
||||
# Configuration file for the Sphinx documentation builder.
|
||||
#
|
||||
# This file only contains a selection of the most common options. For a full
|
||||
# list see the documentation:
|
||||
# https://www.sphinx-doc.org/en/master/usage/configuration.html
|
||||
|
||||
# -- Path setup --------------------------------------------------------------
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#
|
||||
import os
|
||||
import sys
|
||||
|
||||
# sys.path.insert(0, os.path.abspath('.'))
|
||||
# sys.path.insert(0, os.path.abspath('..'))
|
||||
sys.path.insert(0, os.path.abspath("../.."))
|
||||
|
||||
|
||||
# -- Project information -----------------------------------------------------
|
||||
|
||||
project = "PACKAGE_NAME"
|
||||
copyright = "2022, ECMWF"
|
||||
author = "ECMWF"
|
||||
|
||||
|
||||
# -- General configuration ---------------------------------------------------
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
"sphinx.ext.autodoc",
|
||||
"sphinx.ext.napoleon",
|
||||
]
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ["_templates"]
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
# This pattern also affects html_static_path and html_extra_path.
|
||||
exclude_patterns = []
|
||||
|
||||
|
||||
# -- 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 = "alabaster"
|
||||
|
||||
# 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"]
|
42
docs/source/getting_started/installing.rst
Normal file
42
docs/source/getting_started/installing.rst
Normal file
@ -0,0 +1,42 @@
|
||||
.. _installing:
|
||||
|
||||
Installing
|
||||
==========
|
||||
|
||||
|
||||
Pip install
|
||||
-----------
|
||||
|
||||
To install PACKAGE_NAME, just run the following command:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
pip install PACKAGE_NAME
|
||||
|
||||
The PACKAGE_NAME ``pip`` package has been tested successfully with the latest versions of
|
||||
its dependencies (`build logs <https://github.com/PROJECT/PACKAGE_NAME/PATH/TO/test-and-release.yml>`_).
|
||||
|
||||
Conda install
|
||||
-------------
|
||||
|
||||
No conda package has been created yet.
|
||||
``pip install PACKAGE_NAME`` can be used in a conda environment.
|
||||
|
||||
.. note::
|
||||
|
||||
Mixing ``pip`` and ``conda`` could create some dependencies issues,
|
||||
we recommend installing as many dependencies as possible with conda,
|
||||
then install PACKAGE_NAME with ``pip``, `as recommended by the anaconda team
|
||||
<https://www.anaconda.com/blog/using-pip-in-a-conda-environment>`_.
|
||||
|
||||
|
||||
Troubleshooting
|
||||
---------------
|
||||
|
||||
Python 3.7 or above is required
|
||||
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
|
||||
|
||||
PACKAGE_NAME requires Python 3.7 or above. Depending on your installation,
|
||||
you may need to substitute ``pip`` to ``pip3`` in the examples below.
|
||||
|
||||
|
8
docs/source/getting_started/overview.rst
Normal file
8
docs/source/getting_started/overview.rst
Normal file
@ -0,0 +1,8 @@
|
||||
.. _overview:
|
||||
|
||||
Overview
|
||||
========
|
||||
|
||||
|
||||
This package is a template
|
||||
|
43
docs/source/index.rst
Normal file
43
docs/source/index.rst
Normal file
@ -0,0 +1,43 @@
|
||||
.. PACKAGE_NAME documentation master file, created by
|
||||
sphinx-quickstart on Wed Mar 30 16:04:07 2022.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
Welcome to PACKAGE_NAME's documentation!
|
||||
========================================
|
||||
|
||||
Documentation
|
||||
_____________
|
||||
|
||||
**Getting Started**
|
||||
|
||||
* :doc:`getting_started/overview`
|
||||
* :doc:`getting_started/installing`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
:caption: Getting Started
|
||||
|
||||
getting_started/overview
|
||||
getting_started/installing
|
||||
|
||||
**Reference**
|
||||
|
||||
* :doc:`reference/api`
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
:hidden:
|
||||
:caption: Reference
|
||||
|
||||
reference/api
|
||||
|
||||
License
|
||||
-------
|
||||
|
||||
*PACKAGE_NAME* is available under the open source `Apache License`__.
|
||||
|
||||
__ http://www.apache.org/licenses/LICENSE-2.0.html
|
||||
|
||||
|
21
docs/source/reference/PACKAGE_NAME.rst
Normal file
21
docs/source/reference/PACKAGE_NAME.rst
Normal file
@ -0,0 +1,21 @@
|
||||
PACKAGE\_NAME package
|
||||
=====================
|
||||
|
||||
Submodules
|
||||
----------
|
||||
|
||||
PACKAGE\_NAME.sample module
|
||||
---------------------------
|
||||
|
||||
.. automodule:: PACKAGE_NAME.sample
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
||||
|
||||
Module contents
|
||||
---------------
|
||||
|
||||
.. automodule:: PACKAGE_NAME
|
||||
:members:
|
||||
:undoc-members:
|
||||
:show-inheritance:
|
7
docs/source/reference/api.rst
Normal file
7
docs/source/reference/api.rst
Normal file
@ -0,0 +1,7 @@
|
||||
API reference
|
||||
=============
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 4
|
||||
|
||||
PACKAGE_NAME
|
3
pytest.ini
Normal file
3
pytest.ini
Normal file
@ -0,0 +1,3 @@
|
||||
[pytest]
|
||||
addopts=-s --verbose
|
||||
testpaths = tests
|
2
requirements.txt
Normal file
2
requirements.txt
Normal file
@ -0,0 +1,2 @@
|
||||
numpy
|
||||
pytest[tests]
|
58
setup.py
Normal file
58
setup.py
Normal file
@ -0,0 +1,58 @@
|
||||
# (C) Copyright 1996- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||
# granted to it by virtue of its status as an intergovernmental organisation
|
||||
# nor does it submit to any jurisdiction.
|
||||
|
||||
import io
|
||||
import os
|
||||
|
||||
import setuptools
|
||||
|
||||
|
||||
def read(fname):
|
||||
file_path = os.path.join(os.path.dirname(__file__), fname)
|
||||
return io.open(file_path, encoding="utf-8").read()
|
||||
|
||||
|
||||
install_requires = ["numpy"]
|
||||
tests_require = ["pytest"]
|
||||
|
||||
meta = {}
|
||||
exec(read("PACKAGE_NAME/__meta__.py"), meta)
|
||||
|
||||
|
||||
setuptools.setup(
|
||||
# Essential details on the package and its dependencies
|
||||
name=meta["__name__"],
|
||||
version=meta["__version__"],
|
||||
description=meta.get("__description__", ""),
|
||||
long_description=read("README.rst"),
|
||||
author=meta.get(
|
||||
"__author__", "European Centre for Medium-Range Weather Forecasts (ECMWF)"
|
||||
),
|
||||
author_email=meta.get("__author_email__", "software.support@ecmwf.int"),
|
||||
license="Apache License Version 2.0",
|
||||
url="https://github.com/ecmwf-projects/python-package-template-repo",
|
||||
packages=setuptools.find_packages(),
|
||||
include_package_data=True,
|
||||
install_requires=install_requires,
|
||||
zip_safe=True,
|
||||
classifiers=[
|
||||
"Intended Audience :: Developers",
|
||||
"License :: OSI Approved :: Apache Software License",
|
||||
"Programming Language :: Python :: 3",
|
||||
"Programming Language :: Python :: 3.6",
|
||||
"Programming Language :: Python :: 3.7",
|
||||
"Programming Language :: Python :: 3.8",
|
||||
"Programming Language :: Python :: 3.9",
|
||||
"Programming Language :: Python :: 3.10",
|
||||
"Programming Language :: Python :: Implementation :: CPython",
|
||||
"Programming Language :: Python :: Implementation :: PyPy",
|
||||
"Operating System :: OS Independent",
|
||||
],
|
||||
tests_require=tests_require,
|
||||
test_suite="tests",
|
||||
)
|
0
tests/__init__.py
Normal file
0
tests/__init__.py
Normal file
37
tests/test_sample.py
Normal file
37
tests/test_sample.py
Normal file
@ -0,0 +1,37 @@
|
||||
# (C) Copyright 1996- ECMWF.
|
||||
#
|
||||
# This software is licensed under the terms of the Apache Licence Version 2.0
|
||||
# which can be obtained at http://www.apache.org/licenses/LICENSE-2.0.
|
||||
# In applying this licence, ECMWF does not waive the privileges and immunities
|
||||
# granted to it by virtue of its status as an intergovernmental organisation
|
||||
# nor does it submit to any jurisdiction.
|
||||
|
||||
"""
|
||||
Demo tests for raw template.
|
||||
"""
|
||||
|
||||
import unittest
|
||||
|
||||
from PACKAGE_NAME.sample import speed_direction_to_uv
|
||||
|
||||
|
||||
class TestSpeedDirectionToUV(unittest.TestCase):
|
||||
def test_zero_speed(self):
|
||||
# Test that a wind speed of 0 results in u and v values of 0
|
||||
self.assertEqual(speed_direction_to_uv(0, 10), (0, 0))
|
||||
|
||||
def test_zero_direction(self):
|
||||
# Test that a wind direction of 0 results u==speed and v==0
|
||||
self.assertEqual(speed_direction_to_uv(10, 0), (10, 0))
|
||||
|
||||
def test_180_direction(self):
|
||||
# Test that a wind direction of 180 results u==-speed and v==0
|
||||
wind_u, wind_v = speed_direction_to_uv(10, 180)
|
||||
self.assertEqual(wind_u, -10)
|
||||
self.assertAlmostEqual(wind_v, 0)
|
||||
|
||||
def test_90_direction(self):
|
||||
# Test that a wind direction of 90 results u==0 and v==speed
|
||||
wind_u, wind_v = speed_direction_to_uv(10, 90)
|
||||
self.assertAlmostEqual(wind_u, 0)
|
||||
self.assertEqual(wind_v, 10)
|
Loading…
x
Reference in New Issue
Block a user