# Buggy code
def _get_and_verify_data_sizes(data, n_signals=None, n_times=None, times=None):
    """Get and/or verify the data sizes and time scales."""
    if not isinstance(data, (list, tuple)):
        raise ValueError("data has to be a list or tuple")
    n_signals_tot = 0
    for this_data in data:
        this_n_signals, this_n_times = this_data.shape
        if n_times is not None:
            if this_n_times != n_times:
                raise ValueError(
                    "all input time series must have the same number of time points"
                )
        else:
            n_times = this_n_times
        n_signals_tot += this_n_signals

        if hasattr(this_data, "times"):
            this_times = this_data.times
            if times is not None:
                if np.any(times != this_times):
                    warn("time scales of input time series do not match")
            else:
                times = this_times

    if n_signals is not None:
        if n_signals != n_signals_tot:
            raise ValueError(
                "the number of time series has to be the same in each epoch"
            )
    n_signals = n_signals_tot

    return n_signals, n_times, times


# Traceback (ValueError)
Connectivity computation...
Traceback (most recent call last):
File "/home/ap/PycharmProjects/eeg_processing/conn_example.py", line 30, in <module>
faverage=True, tmin=tmin, tmax=tmax, mt_adaptive=False, n_jobs=1)
File "<decorator-gen-387>", line 21, in spectral_connectivity
File "/home/ap/miniconda3/envs/MNE/lib/python3.7/site-packages/mne/connectivity/spectral.py", line 789, in spectral_connectivity
cwt_freqs=cwt_freqs, faverage=faverage)
File "/home/ap/miniconda3/envs/MNE/lib/python3.7/site-packages/mne/connectivity/spectral.py", line 948, in _prepare_connectivity
mask = _time_mask(times_in, tmin, tmax, sfreq=sfreq)
File "/home/ap/miniconda3/envs/MNE/lib/python3.7/site-packages/mne/utils/numerics.py", line 499, in _time_mask
% (orig_tmin, orig_tmax, extra, times[0], times[-1]))
ValueError: No samples remain when using tmin=-0.5 and tmax=-0.1 (original time bounds are [0.0, 2.4974401644798485])

# Fixed code
def _get_and_verify_data_sizes(data, sfreq, n_signals=None, n_times=None, times=None):
    """Get and/or verify the data sizes and time scales."""
    if not isinstance(data, (list, tuple)):
        raise ValueError("data has to be a list or tuple")
    n_signals_tot = 0
    for this_data in data:
        this_n_signals, this_n_times = this_data.shape
        if n_times is not None:
            if this_n_times != n_times:
                raise ValueError(
                    "all input time series must have the same number of time points"
                )
        else:
            n_times = this_n_times
        n_signals_tot += this_n_signals

        if hasattr(this_data, "times"):
            assert isinstance(this_data, _BaseSourceEstimate)
            this_times = this_data.times
            if times is not None:
                if np.any(times != this_times):
                    warn("time scales of input time series do not match")
            else:
                times = this_times
        elif times is None:
            times = _arange_div(n_times, sfreq)

    if n_signals is not None:
        if n_signals != n_signals_tot:
            raise ValueError(
                "the number of time series has to be the same in each epoch"
            )
    n_signals = n_signals_tot

    return n_signals, n_times, times