def _num_samples(x):
 if hasattr(x, 'fit'):
  raise TypeError(('Expected sequence or array-like, got estimator %s' % x))
 if ((not hasattr(x, '__len__')) and (not hasattr(x, 'shape'))):
  if hasattr(x, '__array__'):
   x = np.asarray(x)
  else:
   raise TypeError(('Expected sequence or array-like, got %s' % type(x)))
 if hasattr(x, 'shape'):
  if (len(x.shape) == 0):
   raise TypeError(('Singleton array %r cannot be considered a valid collection.' % x))
  return x.shape[0]
 else:
  return len(x)

def _num_samples ( x ) : if hasattr ( x , 'fit' ) : raise TypeError ( ( 'Expected sequence or array-like, got estimator %s' % x ) ) if ( ( not hasattr ( x , '__len__' ) ) and ( not hasattr ( x , 'shape' ) ) ) : if hasattr ( x , '__array__' ) : x = np . asarray ( x ) else : raise TypeError ( ( 'Expected sequence or array-like, got %s' % type ( x ) ) ) if hasattr ( x , 'shape' ) : if ( len ( x . shape ) == 0 ) : raise TypeError ( ( 'Singleton array %r cannot be considered a valid collection.' % x ) ) return x . shape [ 0 ] else : return len ( x )
return number of samples in array-like x .