def _validate_labels(labels, ndim):
 labels = np.asarray(labels)
 if (labels.dtype.kind not in ('u', 'i')):
  raise ValueError('labels must have int or uint dtype')
 if ((ndim == 1) and (labels.ndim != 1)):
  if ((labels.ndim == 2) and (labels.shape[1] == 1)):
   labels = labels.squeeze()
  else:
   raise ValueError('labels must be 1-dimensional')
 elif ((ndim == 2) and (labels.ndim != 2)):
  raise ValueError('labels must be 2-dimensional, no ragged lists-of-lists')
 return labels

def _validate_labels ( labels , ndim ) : labels = np . asarray ( labels ) if ( labels . dtype . kind not in ( 'u' , 'i' ) ) : raise ValueError ( 'labels must have int or uint dtype' ) if ( ( ndim == 1 ) and ( labels . ndim != 1 ) ) : if ( ( labels . ndim == 2 ) and ( labels . shape [ 1 ] == 1 ) ) : labels = labels . squeeze ( ) else : raise ValueError ( 'labels must be 1-dimensional' ) elif ( ( ndim == 2 ) and ( labels . ndim != 2 ) ) : raise ValueError ( 'labels must be 2-dimensional, no ragged lists-of-lists' ) return labels
check for empty labels in the middle of a label sequence .