# Path: mugen/lists.py
# class MugenList(list):
#     def __init__(self, items: Optional[List[Any]] = None):
#     def __add__(self, rhs):
#     def __getitem__(self, item):
#     def pretty_repr(self, item_reprs: List[str] = None):
#     def lget(self, attr) -> List[Any]:
#     def flatten(self):
# def flatten(list: List[Any]) -> List[Any]:
# 
# Path: mugen/constants.py
# TIME_FORMAT = Union[float, Tuple[int, float], Tuple[int, int, float], str]
# 
# Path: mugen/lists.py
# class MugenList(list):
#     """
#     A subclass of list with extra functionality, used internally
#     """
# 
#     def __init__(self, items: Optional[List[Any]] = None):
#         if items is None:
#             items = []
# 
#         super().__init__(items)
# 
#     def __add__(self, rhs):
#         return type(self)((super().__add__(rhs)))
# 
#     def __getitem__(self, item):
#         result = list.__getitem__(self, item)
#         if isinstance(item, slice):
#             return type(self)(result)
#         else:
#             return result
# 
#     def pretty_repr(self, item_reprs: List[str] = None):
#         if item_reprs is None:
#             item_reprs = [repr(item) for item in self]
# 
#         repr_str = ""
#         for index, element_repr in enumerate(item_reprs):
#             if index != 0:
#                 repr_str += " "
#             repr_str += element_repr
#             if index != len(self) - 1:
#                 repr_str += ", \n"
#         return f"[{repr_str}]"
# 
#     def lget(self, attr) -> List[Any]:
#         """
#         Returns
#         -------
#         A list of values for the attribute, taken from each element in the array
#         """
#         return [getattr(elem, attr) for elem in self]
# 
#     def flatten(self):
#         """
#         Returns
#         -------
#         A new, flattened version of this list.
#         Flattens an arbitrarily nested list of objects
#         """
#         return type(self)(flatten(self))
# 
# Path: mugen/utilities/general.py
# def check_if_ranges_overlap(a_start, a_end, b_start, b_end) -> bool:
# def fill_slices(slices: List[slice], length) -> List[slice]:
# def preprocess_args(func: Callable, variable_names: List[str]):
#     def wrapper(f, *a, **kw):
# 
# Path: mugen/utilities/location.py
# def intervals_from_locations(locations: List[float]) -> List[float]:
# def locations_from_intervals(intervals: List[float]) -> List[float]:
# def start_end_locations_from_locations(
#     locations: List[float],
# ) -> Tuple[List[float], List[float]]:
# def start_end_locations_from_intervals(
#     intervals: List[float],
# ) -> Tuple[List[float], List[float]]:
# 
# Path: mugen/utilities/conversion.py
# def convert_float_to_fraction(*variable_names: str):
#     """
#     Decorator to convert variables from floats to fractions
#     """
#     return preprocess_args(float_to_fraction, *variable_names)
# 
# def convert_time_to_seconds(*variable_names: str):
#     """
#     Decorator to convert variables from TIME_FORMAT to seconds
#     """
#     return preprocess_args(time_to_seconds, *variable_names)


import bisect
import copy
from fractions import Fraction
from functools import wraps
from itertools import groupby, zip_longest
from operator import attrgetter
from typing import List, Optional, Union
from mugen import lists
from mugen.constants import TIME_FORMAT
from mugen.lists import MugenList
from mugen.utilities import general, location
from mugen.utilities.conversion import (
    convert_float_to_fraction,
    convert_time_to_seconds,
)

        return EventGroupList(groups, selected=selected_groups)

    def group_by_slices(self, slices: (int, int)) -> "EventGroupList":
        """
        Groups events by slices.
        Does not support negative indexing.

        Slices explicitly passed in will become selected groups in the resulting EventGroupList.

        Returns
        -------
        An EventGroupList partitioned by slice
        """
        slices = [slice(sl[0], sl[1]) for sl in slices]

        # Fill in rest of slices
        all_slices = general.fill_slices(slices, len(self))
        target_indexes = [index for index, sl in enumerate(all_slices) if sl in slices]

        # Group events by slices
        groups = [self[sl] for sl in all_slices]
        selected_groups = [
            group for index, group in enumerate(groups) if index in target_indexes
        ]
        groups = EventGroupList(groups, selected=selected_groups)

        return groups



# Path: mugen/lists.py
# class MugenList(list):
#     def __init__(self, items: Optional[List[Any]] = None):
#     def __add__(self, rhs):
#     def __getitem__(self, item):
#     def pretty_repr(self, item_reprs: List[str] = None):
#     def lget(self, attr) -> List[Any]:
#     def flatten(self):
# def flatten(list: List[Any]) -> List[Any]:
# 
# Path: mugen/constants.py
# TIME_FORMAT = Union[float, Tuple[int, float], Tuple[int, int, float], str]
# 
# Path: mugen/lists.py
# class MugenList(list):
#     """
#     A subclass of list with extra functionality, used internally
#     """
# 
#     def __init__(self, items: Optional[List[Any]] = None):
#         if items is None:
#             items = []
# 
#         super().__init__(items)
# 
#     def __add__(self, rhs):
#         return type(self)((super().__add__(rhs)))
# 
#     def __getitem__(self, item):
#         result = list.__getitem__(self, item)
#         if isinstance(item, slice):
#             return type(self)(result)
#         else:
#             return result
# 
#     def pretty_repr(self, item_reprs: List[str] = None):
#         if item_reprs is None:
#             item_reprs = [repr(item) for item in self]
# 
#         repr_str = ""
#         for index, element_repr in enumerate(item_reprs):
#             if index != 0:
#                 repr_str += " "
#             repr_str += element_repr
#             if index != len(self) - 1:
#                 repr_str += ", \n"
#         return f"[{repr_str}]"
# 
#     def lget(self, attr) -> List[Any]:
#         """
#         Returns
#         -------
#         A list of values for the attribute, taken from each element in the array
#         """
#         return [getattr(elem, attr) for elem in self]
# 
#     def flatten(self):
#         """
#         Returns
#         -------
#         A new, flattened version of this list.
#         Flattens an arbitrarily nested list of objects
#         """
#         return type(self)(flatten(self))
# 
# Path: mugen/utilities/general.py
# def check_if_ranges_overlap(a_start, a_end, b_start, b_end) -> bool:
# def fill_slices(slices: List[slice], length) -> List[slice]:
# def preprocess_args(func: Callable, variable_names: List[str]):
#     def wrapper(f, *a, **kw):
# 
# Path: mugen/utilities/location.py
# def intervals_from_locations(locations: List[float]) -> List[float]:
# def locations_from_intervals(intervals: List[float]) -> List[float]:
# def start_end_locations_from_locations(
#     locations: List[float],
# ) -> Tuple[List[float], List[float]]:
# def start_end_locations_from_intervals(
#     intervals: List[float],
# ) -> Tuple[List[float], List[float]]:
# 
# Path: mugen/utilities/conversion.py
# def convert_float_to_fraction(*variable_names: str):
#     """
#     Decorator to convert variables from floats to fractions
#     """
#     return preprocess_args(float_to_fraction, *variable_names)
# 
# def convert_time_to_seconds(*variable_names: str):
#     """
#     Decorator to convert variables from TIME_FORMAT to seconds
#     """
#     return preprocess_args(time_to_seconds, *variable_names)


# Path: mugen/events.py
import bisect
import copy
from fractions import Fraction
from functools import wraps
from itertools import groupby, zip_longest
from operator import attrgetter
from typing import List, Optional, Union
from mugen import lists
from mugen.constants import TIME_FORMAT
from mugen.lists import MugenList
from mugen.utilities import general, location
from mugen.utilities.conversion import (
    convert_float_to_fraction,
    convert_time_to_seconds,
)


        return EventGroupList(groups, selected=selected_groups)

    def group_by_slices(self, slices: (int, int)) -> "EventGroupList":
        """
        Groups events by slices.
        Does not support negative indexing.

        Slices explicitly passed in will become selected groups in the resulting EventGroupList.

        Returns
        -------
        An EventGroupList partitioned by slice
        """
        slices = [slice(sl[0], sl[1]) for sl in slices]

        # Fill in rest of slices
        all_slices = general.fill_slices(slices, len(self))
        target_indexes = [index for index, sl in enumerate(all_slices) if sl in slices]

        # Group events by slices
        groups = [self[sl] for sl in all_slices]
        selected_groups = [
            group for index, group in enumerate(groups) if index in target_indexes
        ]
        groups = EventGroupList(groups, selected=selected_groups)

        return groups



class EventGroupList(MugenList):