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))

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 .