def derivative(*args, **kwargs):
    'Get the first derivative of data arrays (*x*, *y*).\n\n    If **y** is not given, the first argument will be taken as **y**, and the\n    differential of the input array will be returned.\n\n    Args:\n        x (list or :class:`numpy.ndarray`): X-values of the input array (optional).\n        y (list or :class:`numpy.ndarray`): Y-values of the input array.\n        points (int): Number of points used to calculate derivative\n            (optional, default is 3).\n\n    Returns:\n        :class:`numpy.ndarray`: Derivative of the input array.\n    '
    if (len(args) == 1):
        y = np.array(args[0], dtype=np.float64)
        x = np.arange(y.size)
    elif (len(args) == 2):
        x = np.array(args[0], dtype=np.float64)
        y = np.array(args[1], dtype=np.float64)
    else:
        raise ValueError
    npts = x.size
    points = kwargs.pop('points', 3)
    if (points == 3):
        der = ((np.roll(y, (- 1)) - np.roll(y, 1)) / (np.roll(x, (- 1)) - np.roll(x, 1)))
        a = np.array([(- 3.0), 4.0, (- 1.0)])
        der[0] = ((a * y[0:3]).sum() / (a * x[0:3]).sum())
        der[(- 1)] = (((- a[::(- 1)]) * y[(- 3):]).sum() / ((- a[::(- 1)]) * x[(- 3):]).sum())
        return der
    else:
        raise ValueError
Get the first derivative of data arrays (*x*, *y*).

If **y** is not given, the first argument will be taken as **y**, and the
differential of the input array will be returned.

Args:
    x (list or :class:`numpy.ndarray`): X-values of the input array (optional).
    y (list or :class:`numpy.ndarray`): Y-values of the input array.
    points (int): Number of points used to calculate derivative
        (optional, default is 3).

Returns:
    :class:`numpy.ndarray`: Derivative of the input array.
def derivative(*args, **kwargs):
    'Get the first derivative of data arrays (*x*, *y*).\n\n    If **y** is not given, the first argument will be taken as **y**, and the\n    differential of the input array will be returned.\n\n    Args:\n        x (list or :class:`numpy.ndarray`): X-values of the input array (optional).\n        y (list or :class:`numpy.ndarray`): Y-values of the input array.\n        points (int): Number of points used to calculate derivative\n            (optional, default is 3).\n\n    Returns:\n        :class:`numpy.ndarray`: Derivative of the input array.\n    '
    if (len(args) == 1):
        y = np.array(args[0], dtype=np.float64)
        x = np.arange(y.size)
    elif (len(args) == 2):
        x = np.array(args[0], dtype=np.float64)
        y = np.array(args[1], dtype=np.float64)
    else:
        raise ValueError
    npts = x.size
    points = kwargs.pop('points', 3)
    if (points == 3):
        der = ((np.roll(y, (- 1)) - np.roll(y, 1)) / (np.roll(x, (- 1)) - np.roll(x, 1)))
        a = np.array([(- 3.0), 4.0, (- 1.0)])
        der[0] = ((a * y[0:3]).sum() / (a * x[0:3]).sum())
        der[(- 1)] = (((- a[::(- 1)]) * y[(- 3):]).sum() / ((- a[::(- 1)]) * x[(- 3):]).sum())
        return der
    else:
        raise ValueError