def _increment_sparse_diagonal_precision(X, mean_vector, covariances, n, graph,
                                         n_features, n_features_per_vertex,
                                         dtype=np.float32, n_components=None,
                                         bias=0, verbose=False):
    # initialize covariances matrix
    all_blocks = 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)

    # Print information if asked
    if verbose:
        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)

    # Compute covariance matrix for each patch
    for v in vertices:
        # find indices in target precision matrix
        i_from = v * n_features_per_vertex
        i_to = (v + 1) * n_features_per_vertex

        # get data
        edge_data = X[:, i_from:i_to]
        m = mean_vector[i_from:i_to]

        # increment
        _, covariances[v] = _increment_multivariate_gaussian_cov(
            edge_data, m, covariances[v], n, bias=bias)

        # invert it
        all_blocks[v] = _covariance_matrix_inverse(covariances[v], n_components)

        # store the inverse covariance and its locations
        rows[v] = v
        columns[v] = v

    # sort rows, columns and all_blocks
    rows_arg_sort = rows.argsort()
    columns = columns[rows_arg_sort]
    all_blocks = all_blocks[rows_arg_sort]
    rows = rows[rows_arg_sort]

    # create indptr
    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

    # create block sparse matrix
    return (bsr_matrix((all_blocks, columns, indptr),
                       shape=(n_features, n_features), dtype=dtype),
            covariances)
dataset/ETHPy150Open menpo/menpo/menpo/model/gmrf.py/_increment_sparse_diagonal_precision/operator `+` -> `%`