Computes a 1D simple moving average along the given axis.

Parameters
----------
array : ndarray
    Array on which to perform the convolution.
window_size: int
    Width of the simple moving average window in indices.
axis : int, optional
    Axis along which to perform the moving average
mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to ‘constant’. Default is ‘reflect’.
kwargs : optional
    Other arguments to pass to `scipy.ndimage.filters.convolve1d`

Returns
-------
sma : ndarray
    Simple moving average of the given array with the specified window size
    along the requested axis.

Raises
------
TypeError:
    If window_size or axis are not integers.

def sma(array, window_size, axis=-1, mode='reflect', **kwargs):
    """
Computes a 1D simple moving average along the given axis.

Parameters
----------
array : ndarray
    Array on which to perform the convolution.
window_size: int
    Width of the simple moving average window in indices.
axis : int, optional
    Axis along which to perform the moving average
mode : {‘reflect’, ‘constant’, ‘nearest’, ‘mirror’, ‘wrap’}, optional
    The mode parameter determines how the array borders are handled, where
    cval is the value when mode is equal to ‘constant’. Default is ‘reflect’.
kwargs : optional
    Other arguments to pass to `scipy.ndimage.filters.convolve1d`

Returns
-------
sma : ndarray
    Simple moving average of the given array with the specified window size
    along the requested axis.

Raises
------
TypeError:
    If window_size or axis are not integers.
    """
    kwargs['axis'] = axis
    kwargs['mode'] = mode
    if not isinstance(window_size, int):
        raise TypeError('window_size must be an integer')
    if not isinstance(kwargs['axis'], int):
        raise TypeError('axis must be an integer')
    return convolve1d(array, np.repeat(1.0, window_size)/window_size, **kwargs)