how_to_write_docstring.py 600 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
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
BO ZHANG's avatar
tweaks    
BO ZHANG committed
17
def cos(x: float = 0.) -> float:
BO ZHANG's avatar
BO ZHANG committed
18
19
20
21
    """ cosine function

    Parameters
    ----------
BO ZHANG's avatar
tweaks    
BO ZHANG committed
22
    x : float
BO ZHANG's avatar
BO ZHANG committed
23
24
25
26
        x values

    Returns
    -------
BO ZHANG's avatar
tweaks    
BO ZHANG committed
27
    cos(x) : float
BO ZHANG's avatar
BO ZHANG committed
28

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)