Skip to content

Latest commit

 

History

History
88 lines (62 loc) · 3.07 KB

for-developers.rst

File metadata and controls

88 lines (62 loc) · 3.07 KB

For Developers

Installing from Source

git clone https://github.com/aditya-grover/climate-learn.git
pip install -e climate-learn

Development and documentation dependencies can be installed by specifying the extras [dev] and [docs], respectively.

Formatting and Linting

ClimateLearn uses black for formatting and flake8 for linting.

black .
flake8 . --count --select=E9,F63,F7,F82 --show-source --statistics

Testing

ClimateLearn uses pytest for testing. Tests can be run as:

pytest tests/

Notes about writing tests:

  1. Import the package as import climate_learn rather than import src.climate_learn.
  2. For tests that require access to resources not available on GitHub Actions Runner, use the following:
# place this at the start of your test script
GITHUB_ACTIONS = os.environ.get("GITHUB_ACTIONS") == "true"

# place this on the line before your test function definition
@pytest.mark.skipif(GITHUB_ACTIONS, reason="only works locally")
def my_local_test(...):
    ... # test function body

Documentation

ClimateLearn uses reStructuredText. Example docstring:

def doc_example_function(arg1, arg2, kwarg1=False):
    r"""One sentence description of the function.
        Use the following lines to talk about what the function does at a
        high level and to provide any necessary additional context.

    .. highlight:: python

    :param arg1: Description of the first argument.
    :type arg1: str
    :param arg2: Description of the second argument.
    :type arg2: int|float
    :param kwarg1: Description of the first keyword argument. Maybe we want
        to use some syntax highlighting here. This can be achieved as such:
        :python:`class MyClass`. Defaults to `False`.
    :type kwarg1: bool, optional
    :returns: Description of what the function returns.
    :rtype: bool
    """
    return False

Suppose this function is available at the top level of the climate_learn package. It can be imported to the docs as such:

.. This is a reStructuredText comment. Maybe this file is at docs/source/file.rst
.. autofunction:: climate_learn.doc_example_function

Further readings: