how_to_write_docstring.py 577 Bytes
Newer Older
BO ZHANG's avatar
BO ZHANG committed
1
2
3
import numpy as np


BO ZHANG's avatar
BO ZHANG committed
4
# a function to be finished
BO ZHANG's avatar
BO ZHANG committed
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
def cos_to_be_finished(x):
    # TODO: to be finished
    return


# a function with a simple docstring
def _cos(x):
    """ this is a cosine function """
    return np.cos(x)


# a function with a complete docstring
def cos(x: float = 0.):
    """ cosine function

    Parameters
    ----------
    x :
        x values

    Returns
    -------
    cos(x)

BO ZHANG's avatar
BO ZHANG committed
29
30
31
32
    Examples
    --------
    >>> import numpy as np
    >>> cos(np.pi)
BO ZHANG's avatar
BO ZHANG committed
33
34
35
36

    Notes
    -----
    this function is a warpper of `numpy.cos()`
BO ZHANG's avatar
BO ZHANG committed
37
38
    """
    return np.cos(x)