def check_nonnegative_integers(X: Union[(np.ndarray, sparse.spmatrix)]):
    'Checks values of X to ensure it is count data'
    from numbers import Integral
    data = (X if isinstance(X, np.ndarray) else X.data)
    if np.signbit(data).any():
        return False
    elif issubclass(data.dtype.type, Integral):
        return True
    elif np.any((~ np.equal(np.mod(data, 1), 0))):
        return False
    else:
        return True
Checks values of X to ensure it is count data
def check_nonnegative_integers(X: Union[(np.ndarray, sparse.spmatrix)]):
    
    from numbers import Integral
    data = (X if isinstance(X, np.ndarray) else X.data)
    if np.signbit(data).any():
        return False
    elif issubclass(data.dtype.type, Integral):
        return True
    elif np.any((~ np.equal(np.mod(data, 1), 0))):
        return False
    else:
        return True