def _check_weighting_scheme(model):
    """Simple wrapper to ensure the weighting scheme is valid for CoreML conversion"""
    is_valid = False
    if model.weights == "uniform":
        is_valid = True

    # Other cases CoreML doesn't support include weighting by distance or a user-provided 'callable' object.

    if not is_valid:
        print_name = ""
        if _is_printable(model.weights):
            print_name = model.weights
        else:
            print_name = getattr(model.weights, "__name__", repr(model.weights))
        raise TypeError(
            "KNeighbors weight function not supported for CoreML conversion: {}".format(
                print_name
            )
        )
Simple wrapper to ensure the weighting scheme is valid for CoreML conversion
coremltools/converters/sklearn/_k_neighbors_classifier.py