From 84925dc8b5eba816eec77bb6dbde0e98ab083b16 Mon Sep 17 00:00:00 2001 From: Tom Date: Tue, 8 Oct 2024 11:48:07 +0100 Subject: [PATCH] Initial commit --- .github/workflows/ci.yml | 43 +++++ .gitignore | 129 +++++++++++++ LICENSE | 201 +++++++++++++++++++++ PACKAGE_NAME/__init__.py | 9 + PACKAGE_NAME/__meta__.py | 16 ++ PACKAGE_NAME/sample.py | 34 ++++ README.rst | 90 +++++++++ docs/Makefile | 20 ++ docs/README.rst | 44 +++++ docs/make.bat | 35 ++++ docs/requirements.txt | 5 + docs/source/conf.py | 57 ++++++ docs/source/getting_started/installing.rst | 42 +++++ docs/source/getting_started/overview.rst | 8 + docs/source/index.rst | 43 +++++ docs/source/reference/PACKAGE_NAME.rst | 21 +++ docs/source/reference/api.rst | 7 + pytest.ini | 3 + requirements.txt | 2 + setup.py | 58 ++++++ tests/__init__.py | 0 tests/test_sample.py | 37 ++++ tox.ini | 8 + 23 files changed, 912 insertions(+) create mode 100644 .github/workflows/ci.yml create mode 100644 .gitignore create mode 100644 LICENSE create mode 100644 PACKAGE_NAME/__init__.py create mode 100644 PACKAGE_NAME/__meta__.py create mode 100644 PACKAGE_NAME/sample.py create mode 100644 README.rst create mode 100644 docs/Makefile create mode 100644 docs/README.rst create mode 100644 docs/make.bat create mode 100644 docs/requirements.txt create mode 100644 docs/source/conf.py create mode 100644 docs/source/getting_started/installing.rst create mode 100644 docs/source/getting_started/overview.rst create mode 100644 docs/source/index.rst create mode 100644 docs/source/reference/PACKAGE_NAME.rst create mode 100644 docs/source/reference/api.rst create mode 100644 pytest.ini create mode 100644 requirements.txt create mode 100644 setup.py create mode 100644 tests/__init__.py create mode 100644 tests/test_sample.py create mode 100644 tox.ini diff --git a/.github/workflows/ci.yml b/.github/workflows/ci.yml new file mode 100644 index 0000000..a46f924 --- /dev/null +++ b/.github/workflows/ci.yml @@ -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 }} \ No newline at end of file diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..b6e4761 --- /dev/null +++ b/.gitignore @@ -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/ diff --git a/LICENSE b/LICENSE new file mode 100644 index 0000000..261eeb9 --- /dev/null +++ b/LICENSE @@ -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. diff --git a/PACKAGE_NAME/__init__.py b/PACKAGE_NAME/__init__.py new file mode 100644 index 0000000..6e4a923 --- /dev/null +++ b/PACKAGE_NAME/__init__.py @@ -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 diff --git a/PACKAGE_NAME/__meta__.py b/PACKAGE_NAME/__meta__.py new file mode 100644 index 0000000..ec9d8b5 --- /dev/null +++ b/PACKAGE_NAME/__meta__.py @@ -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__ = "" diff --git a/PACKAGE_NAME/sample.py b/PACKAGE_NAME/sample.py new file mode 100644 index 0000000..20837dd --- /dev/null +++ b/PACKAGE_NAME/sample.py @@ -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 diff --git a/README.rst b/README.rst new file mode 100644 index 0000000..5e21190 --- /dev/null +++ b/README.rst @@ -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 `_. + +**Quick start** + +Follow these steps to create a new repository from this template. + +#. Click the `Use this template `_ + button and create a new repository with your desired name, location and visibility. + +#. Clone the repository:: + + git clone git@github.com:ecmwf-projects/.git + cd + +#. Remove sample code:: + + rm PACKAGE_NAME/sample.py + rm tests/test_sample.py + +#. Replace ``PACKAGE_NAME`` with your chosen package name:: + + NEW_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 `_ + 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 diff --git a/docs/Makefile b/docs/Makefile new file mode 100644 index 0000000..269cadc --- /dev/null +++ b/docs/Makefile @@ -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) \ No newline at end of file diff --git a/docs/README.rst b/docs/README.rst new file mode 100644 index 0000000..9ff848b --- /dev/null +++ b/docs/README.rst @@ -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 + + + + + diff --git a/docs/make.bat b/docs/make.bat new file mode 100644 index 0000000..5394189 --- /dev/null +++ b/docs/make.bat @@ -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 \ No newline at end of file diff --git a/docs/requirements.txt b/docs/requirements.txt new file mode 100644 index 0000000..88ea917 --- /dev/null +++ b/docs/requirements.txt @@ -0,0 +1,5 @@ +# Requirements for readthedocs +sphinx +ipykernel +nbsphinx +sphinx_rtd_theme \ No newline at end of file diff --git a/docs/source/conf.py b/docs/source/conf.py new file mode 100644 index 0000000..245ddef --- /dev/null +++ b/docs/source/conf.py @@ -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"] diff --git a/docs/source/getting_started/installing.rst b/docs/source/getting_started/installing.rst new file mode 100644 index 0000000..b63e95c --- /dev/null +++ b/docs/source/getting_started/installing.rst @@ -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 `_). + +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 + `_. + + +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. + + diff --git a/docs/source/getting_started/overview.rst b/docs/source/getting_started/overview.rst new file mode 100644 index 0000000..34cb17f --- /dev/null +++ b/docs/source/getting_started/overview.rst @@ -0,0 +1,8 @@ +.. _overview: + +Overview +======== + + +This package is a template + diff --git a/docs/source/index.rst b/docs/source/index.rst new file mode 100644 index 0000000..e7de7eb --- /dev/null +++ b/docs/source/index.rst @@ -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 + + diff --git a/docs/source/reference/PACKAGE_NAME.rst b/docs/source/reference/PACKAGE_NAME.rst new file mode 100644 index 0000000..cb04b8c --- /dev/null +++ b/docs/source/reference/PACKAGE_NAME.rst @@ -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: diff --git a/docs/source/reference/api.rst b/docs/source/reference/api.rst new file mode 100644 index 0000000..23bab81 --- /dev/null +++ b/docs/source/reference/api.rst @@ -0,0 +1,7 @@ +API reference +============= + +.. toctree:: + :maxdepth: 4 + + PACKAGE_NAME diff --git a/pytest.ini b/pytest.ini new file mode 100644 index 0000000..ccc7fe5 --- /dev/null +++ b/pytest.ini @@ -0,0 +1,3 @@ +[pytest] +addopts=-s --verbose +testpaths = tests \ No newline at end of file diff --git a/requirements.txt b/requirements.txt new file mode 100644 index 0000000..cb12bd2 --- /dev/null +++ b/requirements.txt @@ -0,0 +1,2 @@ +numpy +pytest[tests] \ No newline at end of file diff --git a/setup.py b/setup.py new file mode 100644 index 0000000..9979838 --- /dev/null +++ b/setup.py @@ -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", +) diff --git a/tests/__init__.py b/tests/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/tests/test_sample.py b/tests/test_sample.py new file mode 100644 index 0000000..05cb27f --- /dev/null +++ b/tests/test_sample.py @@ -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) diff --git a/tox.ini b/tox.ini new file mode 100644 index 0000000..9fe751b --- /dev/null +++ b/tox.ini @@ -0,0 +1,8 @@ +[flake8] +; ignore = E226,E302,E41 +max-line-length = 120 +; exclude = tests/* +; See https://black.readthedocs.io/en/stable/the_black_code_style.html +extend-ignore = E203 +[isort] +profile=black \ No newline at end of file