parameters: (a, weights)
return_statement: return a, weights
docstring: Check a and weights have matching shapes, and ravel both
docstring_summary: Check a and weights have matching shapes, and ravel both
docstring_tokens: Check a and weights have matching shapes and ravel both
function: def _ravel_and_check_weights(a, weights):
      """ Check a and weights have matching shapes, and ravel both """
      a = np.asarray(a)
  
      # Ensure that the array is a "subtractable" dtype
      if a.dtype == np.bool_:
          warnings.warn("Converting input from {} to {} for compatibility."
                        .format(a.dtype, np.uint8),
                        RuntimeWarning, stacklevel=2)
          a = a.astype(np.uint8)
  
      if weights is not None:
          weights = np.asarray(weights)
          if weights.shape != a.shape:
              raise ValueError(
                  'weights should have the same shape as a.')
          weights = weights.ravel()
      a = a.ravel()
      return a, weights
function_tokens: def _ravel_and_check_weights ( a , weights ) : a = np . asarray ( a ) # Ensure that the array is a "subtractable" dtype if a . dtype == np . bool_ : warnings . warn ( "Converting input from {} to {} for compatibility." . format ( a . dtype , np . uint8 ) , RuntimeWarning , stacklevel = 2 ) a = a . astype ( np . uint8 ) if weights is not None : weights = np . asarray ( weights ) if weights . shape != a . shape : raise ValueError ( 'weights should have the same shape as a.' ) weights = weights . ravel ( ) a = a . ravel ( ) return a , weights