parameters: (self, dim, mean, cov)
return_statement: return dim, mean, cov
docstring: Infer dimensionality from mean or covariance matrix, ensure that
          mean and covariance are full vector resp. matrix.
docstring_summary: Infer dimensionality from mean or covariance matrix, ensure that
          mean and covariance are full vector resp. matrix.
docstring_tokens: Infer dimensionality from mean or covariance matrix ensure that mean and covariance are full vector resp . matrix .
function: def _process_parameters(self, dim, mean, cov):
          """
          Infer dimensionality from mean or covariance matrix, ensure that
          mean and covariance are full vector resp. matrix.
  
          """
  
          # Try to infer dimensionality
          if dim is None:
              if mean is None:
                  if cov is None:
                      dim = 1
                  else:
                      cov = np.asarray(cov, dtype=float)
                      if cov.ndim < 2:
                          dim = 1
                      else:
                          dim = cov.shape[0]
              else:
                  mean = np.asarray(mean, dtype=float)
                  dim = mean.size
          else:
              if not np.isscalar(dim):
                  raise ValueError("Dimension of random variable must be a scalar.")
  
          # Check input sizes and return full arrays for mean and cov if necessary
          if mean is None:
              mean = np.zeros(dim)
          mean = np.asarray(mean, dtype=float)
  
          if cov is None:
              cov = 1.0
          cov = np.asarray(cov, dtype=float)
  
          if dim == 1:
              mean.shape = (1,)
              cov.shape = (1, 1)
  
          if mean.ndim != 1 or mean.shape[0] != dim:
              raise ValueError("Array 'mean' must be a vector of length %d." % dim)
          if cov.ndim == 0:
              cov = cov * np.eye(dim)
          elif cov.ndim == 1:
              cov = np.diag(cov)
          elif cov.ndim == 2 and cov.shape != (dim, dim):
              rows, cols = cov.shape
              if rows != cols:
                  msg = ("Array 'cov' must be square if it is two dimensional,"
                         " but cov.shape = %s." % str(cov.shape))
              else:
                  msg = ("Dimension mismatch: array 'cov' is of shape %s,"
                         " but 'mean' is a vector of length %d.")
                  msg = msg % (str(cov.shape), len(mean))
              raise ValueError(msg)
          elif cov.ndim > 2:
              raise ValueError("Array 'cov' must be at most two-dimensional,"
                               " but cov.ndim = %d" % cov.ndim)
  
          return dim, mean, cov
function_tokens: def _process_parameters ( self , dim , mean , cov ) : # Try to infer dimensionality if dim is None : if mean is None : if cov is None : dim = 1 else : cov = np . asarray ( cov , dtype = float ) if cov . ndim < 2 : dim = 1 else : dim = cov . shape [ 0 ] else : mean = np . asarray ( mean , dtype = float ) dim = mean . size else : if not np . isscalar ( dim ) : raise ValueError ( "Dimension of random variable must be a scalar." ) # Check input sizes and return full arrays for mean and cov if necessary if mean is None : mean = np . zeros ( dim ) mean = np . asarray ( mean , dtype = float ) if cov is None : cov = 1.0 cov = np . asarray ( cov , dtype = float ) if dim == 1 : mean . shape = ( 1 , ) cov . shape = ( 1 , 1 ) if mean . ndim != 1 or mean . shape [ 0 ] != dim : raise ValueError ( "Array 'mean' must be a vector of length %d." % dim ) if cov . ndim == 0 : cov = cov * np . eye ( dim ) elif cov . ndim == 1 : cov = np . diag ( cov ) elif cov . ndim == 2 and cov . shape != ( dim , dim ) : rows , cols = cov . shape if rows != cols : msg = ( "Array 'cov' must be square if it is two dimensional," " but cov.shape = %s." % str ( cov . shape ) ) else : msg = ( "Dimension mismatch: array 'cov' is of shape %s," " but 'mean' is a vector of length %d." ) msg = msg % ( str ( cov . shape ) , len ( mean ) ) raise ValueError ( msg ) elif cov . ndim > 2 : raise ValueError ( "Array 'cov' must be at most two-dimensional," " but cov.ndim = %d" % cov . ndim ) return dim , mean , cov