Loads the CWR default values file, creating a matrix from it, and then
        returns this data.

        The file will only be loaded once.

        :return: the CWR default values matrix
333390
def _load_cwr_defaults(self):
        
        if self._cwr_defaults is None:
            self._cwr_defaults = self._reader.read_yaml_file(
                self._file_defaults)

        return self._cwr_defaults
1269821
def S(self):
        
        if self.c is None:
            raise RuntimeError('Cross-spectral density requires noise '
                               'covariance matrix c.')
        H = self.H()
        # TODO: can we do that more efficiently?
        S = np.empty(H.shape, dtype=H.dtype)
        for f in range(H.shape[2]):
            S[:, :, f] = H[:, :, f].dot(self.c).dot(H[:, :, f].conj().T)
        return S
980129
def load_csv(path):
    
    meta = []
    data = []
    with codecs.open(path, encoding="ASCII") as in_file:
        for line in in_file:
            if line.startswith("#"):
                key, value = line[1:].strip().split(" ", 1)
                meta.append((key, value))   # TODO: There are duplicit entries :-()
            else:
                try:
                    data.append([float(frag) for frag in line.split(",")])
                except:
                    pass
    data = np.asarray(data)
    ndim = int(_get(meta, "dimension"))
    if ndim == 1:
        return _create_h1(data, meta)
    elif ndim == 2:
        return _create_h2(data, meta)
620088
def initialise(self, args=None, env=None, file=None, cwd=None):
        
        self.spec_file = args and args.specs or None
        self.cwd = cwd or os.getcwd()
        self.file = file
        return self.spec_file is not None
233917
def load_csv(file, shape=None, normalize=False):
    
    value_list = []
    if six.PY2:
        for row in csv.reader(file):
            value_list.append(list(map(float, row)))
    elif six.PY34:
        for row in csv.reader([l.decode('utf-8') for l in file.readlines()]):
            value_list.append(list(map(float, row)))
    if shape is None:
        return numpy.array(value_list)
    else:
        return numpy.array(value_list).reshape(shape)
1337119
def get_matrix(self):
        
        return np.array([ self.get_row_list(i) for i in range(self.row_count()) ])
56867
def populateCsv(self):
    
    workingDirPath = createDir(self._workingDir)
    csvPath = os.path.join(workingDirPath, "data.csv")
    self.writeCsv(csvPath)
    return csvPath, workingDirPath
855321
def get_j_ty_callback(self):
        
        j_exprs = self.get_jac()
        if j_exprs is False:
            return None
        cb = self._callback_factory(j_exprs)
        if self.sparse:
            from scipy.sparse import csc_matrix

            def sparse_cb(x, y, p=()):
                data = cb(x, y, p).flatten()
                return csc_matrix((data, self._rowvals, self._colptrs))

            return sparse_cb
        else:
            return cb
1133995
private static Matrix readSVDLIBCsingularVector(File sigmaMatrixFile)
            throws IOException {
        BufferedReader br = 
            new BufferedReader(new FileReader(sigmaMatrixFile)); 

        int dimension = -1;
        int valsSeen = 0;
        Matrix m = null;
        for (String line = null; (line = br.readLine()) != null; ) {
            String[] vals = line.split("\\s+");
            for (int i = 0; i < vals.length; ++i) {
                // the first value seen should be the number of singular values
                if (dimension == -1) {
                    dimension = Integer.parseInt(vals[i]);
                    m = new DiagonalMatrix(dimension);
                }
                else {
                    m.set(valsSeen, valsSeen, Double.parseDouble(vals[i]));
                    ++valsSeen;
                }
            }
        }
        return m;
    }
332176
def _get_values(self):
        
        (gi, _), (ci, _), (si, _) = self._get_dims(self.hmap.last)
        ndims = self.hmap.last.ndims
        dims = self.hmap.last.kdims
        dimensions = []
        values = {}
        for vidx, vtype in zip([gi, ci, si], self._dimensions):
            if vidx < ndims:
                dim = dims[vidx]
                dimensions.append(dim)
                vals = self.hmap.dimension_values(dim.name)
            else:
                dimensions.append(None)
                vals = [None]
            values[vtype] = list(unique_iterator(vals))
        return values, dimensions
636648
def value_dp_matrix(self):
        

        if self.__value_dp_matrix is None:
            self.__value_dp_matrix = self.__dp_extractor.to_dp_matrix(
                to_value_matrix(self.headers, self.rows)
            )

        return self.__value_dp_matrix
1068159
@Nonnull
  @ReturnsMutableCopy
  public Matrix getR ()
  {
    final Matrix aNewMatrix = new Matrix (m_nCols, m_nCols);
    final double [] [] aNewArray = aNewMatrix.internalGetArray ();
    for (int nRow = 0; nRow < m_nCols; nRow++)
    {
      final double [] aDstRow = aNewArray[nRow];
      for (int j = 0; j < m_nCols; j++)
      {
        if (nRow < j)
          aDstRow[j] = m_aQR[nRow][j];
        else
          if (nRow == j)
            aDstRow[j] = m_aRdiag[nRow];
          else
            aDstRow[j] = 0.0;
      }
    }
    return aNewMatrix;
  }
1361461
def eighCovarianceMatrix(cfile):
    
    # precompute eigenvalue decomposition
    K = np.loadtxt(cfile+'.cov')
    K+= 1e-4*sp.eye(K.shape[0])
    S,U = la.eigh(K); S=S[::-1]; U=U[:,::-1]
    np.savetxt(cfile+'.cov.eval',S,fmt='%.6f')
    np.savetxt(cfile+'.cov.evec',U,fmt='%.6f')
84969
def get_header_values(self):
        
        lines = self.getOriginalFile().data.splitlines()
        reader = csv.reader(lines)
        header_fields = header_data = []
        for row in reader:
            if not any(row):
                continue
            if row[0].strip().lower() == 'header':
                header_fields = [x.strip() for x in row][1:]
                continue
            if row[0].strip().lower() == 'header data':
                header_data = [x.strip() for x in row][1:]
                break
        if not (header_data or header_fields):
            return None
        if not (header_data and header_fields):
            self.error("File is missing header row or header data")
            return None
        # inject us out of here
        values = dict(zip(header_fields, header_data))
        # blank cell from sheet will probably make it in here:
        if '' in values:
            del (values[''])
        return values
363956
def get_matrix(self):
        
        data = []
        with open(self.path, encoding=self.encoding) as csv_file:
            csv_reader = csv.reader(csv_file, delimiter=",", quotechar="\"")
            for row in csv_reader:
                data.append(row)

        return data
573707
def get_default_value(self):
        
        default = self.default_value
        if isinstance(default, collections.Callable):
            default = default()
        return default
856779
def fill_defaults(self):
        
        defaults = {'result_quality': 'g',
                    'result_type': 'i',
                    'orientation_quality': 'g',
                    'citations': 'This study'}
        for col_name in defaults:
            if col_name in self.grid.col_labels:
                # try to grab existing values from contribution
                if self.grid_type in self.contribution.tables:
                    if col_name in self.contribution.tables[self.grid_type].df.columns:
                        old_vals = self.contribution.tables[self.grid_type].df[col_name]
                        # if column is completely filled in, skip
                        if all([cb.not_null(val, False) for val in old_vals]):
                            continue
                        new_val = defaults[col_name]
                        vals = list(np.where((old_vals.notnull()) & (old_vals != ''), old_vals, new_val))
                    else:
                        vals = [defaults[col_name]] * self.grid.GetNumberRows()
                # if values not available in contribution, use defaults
                else:
                    vals = [defaults[col_name]] * self.grid.GetNumberRows()
            # if col_name not present in grid, skip
            else:
                vals = None
            #
            if vals:
                print('-I- Updating column "{}" with default values'.format(col_name))
                if self.huge:
                    self.grid.SetColumnValues(col_name, vals)
                else:
                    col_ind = self.grid.col_labels.index(col_name)
                    for row, val in enumerate(vals):
                        self.grid.SetCellValue(row, col_ind, val)
                        self.grid.changes = set(range(self.grid.GetNumberRows()))