import copy


def cut(motion, frame_start, frame_end):
    """
    Returns motion object with poses from [frame_start, frame_end) only. The
    operation is not done in-place.

    Args:
        motion: Motion sequence to be cut
        frame_start, frame_end: Frame number range that defines the boundary of
            motion to be cut. Pose at frame_start is included, and pose at
            frame_end is excluded in the returned motion object
    """
    cut_motion = copy.deepcopy(motion)
    cut_motion.name = f"{motion.name}_{frame_start}_{frame_end}"
    cut_motion.poses = motion.poses[frame_start:frame_end]

    return cut_motion