Contribution start guide

The preferred way to start contributing for the project is creating a virtualenv (you can do by using virtualenv, virtualenvwrapper, pyenv or whatever tool you’d like). Only Python 3.x are supported

Preparing the eviroment

Create the virtualenv:

mkvirtualenv hrv

Install all dependencies:

pip install -r requirements.txt

Install development dependencies:

pip install -r dev-requirements.txt

Running the tests

In order to run the tests, activate the virtualenv and execute pytest:

workon <virtualenv>
pytest -v
# or
make test

Coding and Docstring styles

Generally, we try to use Python common styles conventions as described in PEP 8 and PEP 257, which are also followed by the numpy project.

Example

def moving_average(rri, order=3):
    """
    Low-pass filter. Replace each RRi value by the average of its ⌊N/2⌋
    neighbors. The first and the last ⌊N/2⌋ RRi values are not filtered

    Parameters
    ----------
    rri : array_like
    sequence containing the RRi series
    order : int, optional
    Strength of the filter. Number of adjacent RRi values used to calculate
    the average value to replace the current RRi. Defaults to 3.

    .. math::
    considering movinge average of order equal to 3:
    RRi[j] = sum(RRi[j-2] + RRi[j-1] + RRi[j+1] + RRi[j+2]) / 3

    Returns
    -------
    results : RRi array
    instance of the RRi class containing the filtered RRi values

    See Also
    -------
    moving_median, threshold_filter, quotient

    Examples
    --------
    >>> from hrv.filters import moving_average
    >>> from hrv.sampledata import load_noisy_rri
    >>> noisy_rri = load_noisy_rri()
    >>> moving_average(noisy_rri)
    RRi array([904., 918., 941.66666667, ..., 732.66666667, 772.33333, 808.])
    """

We also encourage the use of code linters, such isort , black and autoflake.

autoflake --in-place --recursive --remove-unused-variables --remove-all-unused-imports .
sort -rc .
black .