def bin_edge_summary(r, binfit):
    """
    Return a summary of the bin edges.

    Parameters
    ----------
    r : `numpy.ndarray`
        An array of bin edges of shape (2, nbins) where nbins is the number of
        bins.
    binfit : {'center' | 'left' | 'right'}
        How to summarize the bin edges.

    Returns
    -------
    `numpy.ndarray`
        A one dimensional array of values that summarize the location of the bins.
    """
    if r.ndim != 2:
        raise ValueError(
            'The bin edges must be two-dimensional with shape (2, nbins).')
    if r.shape[0] != 2:
        raise ValueError(
            'The bin edges must be two-dimensional with shape (2, nbins).')
    if binfit == 'center':
        summary = 0.5 * (r[(0), :] + r[(1), :])
    elif binfit == 'left':
        summary = r[(0), :]
    elif binfit == 'right':
        summary = r[(1), :]
    else:
        raise ValueError(
            'Keyword "binfit" must have value "center", "left" or "right"')
    return summary
