def check_non_negative(X, whom):
    X = X.data if sp.issparse(X) else X
    if (X < 0).any():
        raise ValueError("Negative values in data passed to %s" % whom)
Check if there is any negative value in an array.
dataset/ETHPy150Open scikit-learn/scikit-learn/sklearn/utils/validation.py/check_non_negative