def _check_weights(weights):
    """Check to make sure weights are valid"""
    if weights in (None, 'uniform', 'distance'):
        return weights
    elif callable(weights):
        return weights
    else:
        raise ValueError(
            "weights not recognized: should be 'uniform', 'distance', or a callable function"
            )
