def _calc_binsize(num_bins, t_start, t_stop):
    """
    Calculates the stop point from given parameters.

    Calculates the size of bins `binsize` from the three parameters
    `num_bins`, `t_start` and `t_stop`.

    Parameters
    ----------
    num_bins : int
        Number of bins
    t_start : pq.Quantity
        Start time
    t_stop : pq.Quantity
        Stop time

    Returns
    -------
    binsize : pq.Quantity
        Size of bins calculated from given parameters.

    Raises
    ------
    ValueError
        When `t_stop` is smaller than `t_start`.
    """
    if num_bins is not None and t_start is not None and t_stop is not None:
        if t_stop < t_start:
            raise ValueError('t_stop (%s) is smaller than t_start (%s)' % (
                t_stop, t_start))
        return (t_stop - t_start) / num_bins
