def _check_matrix_is_sparse(func):
    @wraps(func)
    def wrapper(*args, **kwargs):
        if 'accept_sparse' in kwargs and not sparse.isspmatrix(args[0]):
            raise TypeError('A dense matrix was passed in, but sparse'
                            'data is required.')
        result = func(*args, **kwargs)
        return result
    return wrapper
Check that input is a scipy sparse matrix and raise warning otherwise.
dataset/ETHPy150Open ibayer/fastFM/fastFM/validation.py/_check_matrix_is_sparse