def keep_merge(walkers, keep_idx):
    """Merge a set of walkers using the state of one of them.

    Parameters
    ----------
    walkers : list of objects implementing the Walker interface
        The walkers that will be merged together
    keep_idx : int
        The index of the walker in the walkers list that will be used
        to set the state of the new merged walker.

    Returns
    -------
    merged_walker : object implementing the Walker interface

    """

    weights = [walker.weight for walker in walkers]
    # but we add their weight to the new walker
    new_weight = sum(weights)
    # create a new walker with the keep_walker state
    new_walker = type(walkers[0])(walkers[keep_idx].state, new_weight)

    return new_walker