

def _create_sparse_diagonal_precision(X, graph, n_features, n_features_per_vertex, dtype=np.float32, n_components=None, bias=0, return_covariances=False, verbose=False):
    all_blocks = np.zeros((graph.n_vertices, n_features_per_vertex, n_features_per_vertex), dtype=dtype)
    if return_covariances:
        all_covariances = np.zeros((graph.n_vertices, n_features_per_vertex, n_features_per_vertex), dtype=dtype)
    columns = np.zeros(graph.n_vertices)
    rows = np.zeros(graph.n_vertices)
    if vertices:
        vertices = print_progress(range(graph.n_vertices), n_items=graph.n_vertices, prefix='Precision per vertex', end_with_newline=False)
    else:
        vertices = range(graph.n_vertices)
    for v in vertices:
        i_from = (v * n_features_per_vertex)
        i_to = ((v + 1) * n_features_per_vertex)
        covmat = np.cov(X[:, i_from:i_to], rowvar=0, bias=bias)
        if return_covariances:
            all_covariances[v] = covmat
        all_blocks[v] = _covariance_matrix_inverse(covmat, n_components)
        rows[v] = v
        columns[v] = v
    rows_arg_sort = rows.argsort()
    columns = columns[rows_arg_sort]
    all_blocks = all_blocks[rows_arg_sort]
    rows = rows[rows_arg_sort]
    n_rows = graph.n_vertices
    indptr = np.zeros((n_rows + 1))
    for i in range(n_rows):
        (inds,) = np.where((rows == i))
        if (inds.size == 0):
            indptr[(i + 1)] = indptr[i]
        else:
            indptr[i] = inds[0]
            indptr[(i + 1)] = (inds[(- 1)] + 1)
    if return_covariances:
        return (bsr_matrix((all_blocks, columns, indptr), shape=(n_features, n_features), dtype=dtype), all_covariances)
    else:
        return bsr_matrix((all_blocks, columns, indptr), shape=(n_features, n_features), dtype=dtype)

dataset/ETHPy150Open menpo/menpo/menpo/model/gmrf.py _create_sparse_diagonal_precision/VarMisuse@109/163 `verbose`->`vertices`