def _get_sigma(sigma, nobs):
 if (sigma is None):
  return (None, None)
 sigma = np.asarray(sigma).squeeze()
 if (sigma.ndim == 0):
  sigma = np.repeat(sigma, nobs)
 if (sigma.ndim == 1):
  if (sigma.shape != (nobs,)):
   raise ValueError(('Sigma must be a scalar, 1d of length %s or a 2d array of shape %s x %s' % (nobs, nobs, nobs)))
  cholsigmainv = (1 / np.sqrt(sigma))
 else:
  if (sigma.shape != (nobs, nobs)):
   raise ValueError(('Sigma must be a scalar, 1d of length %s or a 2d array of shape %s x %s' % (nobs, nobs, nobs)))
  cholsigmainv = np.linalg.cholesky(np.linalg.pinv(sigma)).T
 return (sigma, cholsigmainv)

def _get_sigma ( sigma , nobs ) : if ( sigma is None ) : return ( None , None ) sigma = np . asarray ( sigma ) . squeeze ( ) if ( sigma . ndim == 0 ) : sigma = np . repeat ( sigma , nobs ) if ( sigma . ndim == 1 ) : if ( sigma . shape != ( nobs , ) ) : raise ValueError ( ( 'Sigma must be a scalar, 1d of length %s or a 2d array of shape %s x %s' % ( nobs , nobs , nobs ) ) ) cholsigmainv = ( 1 / np . sqrt ( sigma ) ) else : if ( sigma . shape != ( nobs , nobs ) ) : raise ValueError ( ( 'Sigma must be a scalar, 1d of length %s or a 2d array of shape %s x %s' % ( nobs , nobs , nobs ) ) ) cholsigmainv = np . linalg . cholesky ( np . linalg . pinv ( sigma ) ) . T return ( sigma , cholsigmainv )
returns sigma for gls and the inverse of its cholesky decomposition .