@classmethod
def from_events(cls, events, window=5):
    """ Return a Segments object created from the given discrete times.

        Parameters
        ----------
        events (array_like) : List containing discrete time integer events.

        window (int, optional) : Size of window to be applied with the event at
        its center. The window has to be greater than 0.

        Returns
        -------
        segments (Segments) : Segments object created from the given events.
        """
    assert window > 0
    tmp_list = []
    half_window = window // 2
    for event in events:
        start = event - half_window
        time_window = list(range(int(start), int(start + window)))
        tmp_list.extend(time_window)
    segments = cls()
    segments.segments = set(tmp_list)
    segments.nb_events = len(events)
    return segments
