original_docstring: Return number of samples in array-like x.
docstring: Return number of samples in array-like x.
docstring_tokens: Return number of samples in array - like x .
code: def _num_samples(x):
      """Return number of samples in array-like x."""
      message = 'Expected sequence or array-like, got %s' % type(x)
      if hasattr(x, 'fit') and callable(x.fit):
          # Don't get num_samples from an ensembles length!
          raise TypeError(message)
  
      if not hasattr(x, '__len__') and not hasattr(x, 'shape'):
          if hasattr(x, '__array__'):
              x = np.asarray(x)
          else:
              raise TypeError(message)
  
      if hasattr(x, 'shape') and x.shape is not None:
          if len(x.shape) == 0:
              raise TypeError("Singleton array %r cannot be considered"
                              " a valid collection." % x)
          # Check that shape is returning an integer or default to len
          # Dask dataframes may not return numeric shape[0] value
          if isinstance(x.shape[0], numbers.Integral):
              return x.shape[0]
  
      try:
          return len(x)
      except TypeError:
          raise TypeError(message)
code_tokens: def _num_samples ( x ) : message = 'Expected sequence or array-like, got %s' % type ( x ) if hasattr ( x , 'fit' ) and callable ( x . fit ) : raise TypeError ( message ) if not hasattr ( x , '__len__' ) and not hasattr ( x , 'shape' ) : if hasattr ( x , '__array__' ) : x = np . asarray ( x ) else : raise TypeError ( message ) if hasattr ( x , 'shape' ) and x . shape is not None : if len ( x . shape ) == 0 : raise TypeError ( "Singleton array %r cannot be considered" " a valid collection." % x ) if isinstance ( x . shape [ 0 ] , numbers . Integral ) : return x . shape [ 0 ] try : return len ( x ) except TypeError : raise TypeError ( message )
short_docstring: Return number of samples in array-like x.
short_docstring_tokens: Return number of samples in array - like x .
comment: """Return number of samples in array-like x."""$SEP$# Don't get num_samples from an ensembles length!$SEP$# Check that shape is returning an integer or default to len$SEP$# Dask dataframes may not return numeric shape[0] value