Traverses memory, to annotate all the labels in the global
    LABELS table
437709
def get_labels(MEMORY, basic_block):
    
    for cell in MEMORY:
        if cell.is_label:
            label = cell.inst
            LABELS[label] = LabelInfo(label, cell.addr, basic_block)
326658
def get(self, cid1, cid2, annotator_id):
        '''
        '''
        t = (cid1, cid2, annotator_id)
        for k, v in self.kvl.scan(self.TABLE, (t, t)):
            return self._label_from_kvlayer(k, v)
1186646
public void visitAnnotations(AnnotatedNode node) {
        super.visitAnnotations(node);
        for (AnnotationNode an : node.getAnnotations()) {
            String name = an.getClassNode().getName();
            if ((GRAB_CLASS_NAME.equals(name))
                    || (allowShortGrab && GRAB_SHORT_NAME.equals(name))
                    || (grabAliases.contains(name))) {
                grabAnnotations.add(an);
            }
            if ((GRABEXCLUDE_CLASS_NAME.equals(name))
                    || (allowShortGrabExcludes && GRABEXCLUDE_SHORT_NAME.equals(name))
                    || (grabExcludeAliases.contains(name))) {
                grabExcludeAnnotations.add(an);
            }
            if ((GRABCONFIG_CLASS_NAME.equals(name))
                    || (allowShortGrabConfig && GRABCONFIG_SHORT_NAME.equals(name))
                    || (grabConfigAliases.contains(name))) {
                grabConfigAnnotations.add(an);
            }
            if ((GRAPES_CLASS_NAME.equals(name))
                    || (allowShortGrapes && GRAPES_SHORT_NAME.equals(name))
                    || (grapesAliases.contains(name))) {
                grapesAnnotations.add(an);
            }
            if ((GRABRESOLVER_CLASS_NAME.equals(name))
                    || (allowShortGrabResolver && GRABRESOLVER_SHORT_NAME.equals(name))
                    || (grabResolverAliases.contains(name))) {
                grabResolverAnnotations.add(an);
            }
        }
    }
1358079
def _stmt_graph_annotate_edges(self, edges_to_annotate, **new_labels):
        

        graph = self.graph

        for src, dst in edges_to_annotate:

            if src not in graph:
                continue
            if dst not in graph[src]:
                continue

            data = graph[src][dst]

            for k, v in new_labels.items():
                if k in data:
                    if v not in data[k]:
                        data[k] = data[k] + (v,)
                else:
                    # Construct a tuple
                    data[k] = (v,)
814946
def label(self):
        """""""
        for c in self.table.columns:
            if c.parent == self.name and 'label' in c.valuetype:
                return PartitionColumn(c, self._partition)
282524
def annotation_rows(prefix, annotations):
    
    ncol = len(annotations['Column Name'])
    return {name.replace(prefix, '', 1) : values + [''] * (ncol - len(values))
            for name, values in annotations.items() if name.startswith(prefix)}
178852
def update_annotations(self):
        
        start_time = self.parent.overview.start_time

        if self.parent.notes.annot is None:
            all_annot = []
        else:
            bookmarks = self.parent.notes.annot.get_bookmarks()
            events = self.get_selected_events()

            all_annot = bookmarks + events
            all_annot = sorted(all_annot, key=lambda x: x['start'])

        self.idx_annot_list.clearContents()
        self.idx_annot_list.setRowCount(len(all_annot))

        for i, mrk in enumerate(all_annot):
            abs_time = (start_time +
                        timedelta(seconds=mrk['start'])).strftime('%H:%M:%S')
            dur = timedelta(seconds=mrk['end'] - mrk['start'])
            duration = '{0:02d}.{1:03d}'.format(dur.seconds,
                                                round(dur.microseconds / 1000))

            item_time = QTableWidgetItem(abs_time)
            item_duration = QTableWidgetItem(duration)
            item_name = QTableWidgetItem(mrk['name'])
            if mrk in bookmarks:
                item_type = QTableWidgetItem('bookmark')
                color = self.parent.value('annot_bookmark_color')
            else:
                item_type = QTableWidgetItem('event')
                color = convert_name_to_color(mrk['name'])
            chan = mrk['chan']
            if isinstance(chan, (tuple, list)):
                chan = ', '.join(chan)
            item_chan = QTableWidgetItem(chan)

            item_time.setForeground(QColor(color))
            item_duration.setForeground(QColor(color))
            item_name.setForeground(QColor(color))
            item_type.setForeground(QColor(color))
            item_chan.setForeground(QColor(color))

            self.idx_annot_list.setItem(i, 0, item_time)
            self.idx_annot_list.setItem(i, 1, item_duration)
            self.idx_annot_list.setItem(i, 2, item_name)
            self.idx_annot_list.setItem(i, 3, item_type)
            self.idx_annot_list.setItem(i, 4, item_chan)

        # store information about the time as list (easy to access)
        annot_start = [ann['start'] for ann in all_annot]
        annot_end = [ann['end'] for ann in all_annot]
        annot_name = [ann['name'] for ann in all_annot]
        self.idx_annot_list.setProperty('start', annot_start)
        self.idx_annot_list.setProperty('end', annot_end)
        self.idx_annot_list.setProperty('name', annot_name)

        if self.parent.traces.data is not None:
            self.parent.traces.display_annotations()
        self.parent.overview.display_annotations()
58136
def display_annotations(self):
        
        for rect in self.idx_annot:
            self.scene.removeItem(rect)
        self.idx_annot = []

        if self.parent.notes.annot is None:
            return

        bookmarks = []
        events = []
        if self.parent.value('annot_show'):
            bookmarks = self.parent.notes.annot.get_bookmarks()
            events = self.parent.notes.get_selected_events()

        annotations = bookmarks + events

        for annot in annotations:
            rect = QGraphicsRectItem(annot['start'],
                                     BARS['annot']['pos0'],
                                     annot['end'] - annot['start'],
                                     BARS['annot']['pos1'])
            self.scene.addItem(rect)

            if annot in bookmarks:
                color = self.parent.value('annot_bookmark_color')
            if annot in events:
                color = convert_name_to_color(annot['name'])

            rect.setPen(QPen(QColor(color), LINE_WIDTH))
            rect.setBrush(QBrush(QColor(color)))
            rect.setZValue(-5)
            self.idx_annot.append(rect)

        for epoch in self.parent.notes.annot.epochs:
            self.mark_stages(epoch['start'],
                             epoch['end'] - epoch['start'],
                             epoch['stage'])
            self.mark_quality(epoch['start'],
                              epoch['end'] - epoch['start'],
                              epoch['quality'])

        cycles = self.parent.notes.annot.rater.find('cycles')
        cyc_starts = [float(mrkr.text) for mrkr in cycles.findall('cyc_start')]
        cyc_ends = [float(mrkr.text) for mrkr in cycles.findall('cyc_end')]

        for mrkr in cyc_starts:
            self.mark_cycles(mrkr, 30) # TODO: better width solution
        for mrkr in cyc_ends:
            self.mark_cycles(mrkr, 30, end=True)
715992
def labels(self):
        
        if self._labels is None:
            self._labels = map(self.labelFormat().format, self.values())
        return self._labels
919370
def node_labels(node_labels, node_indices):
    """"""
    if len(node_labels) != len(node_indices):
        raise ValueError("Labels {0} must label every node {1}.".format(
            node_labels, node_indices))

    if len(node_labels) != len(set(node_labels)):
        raise ValueError("Labels {0} must be unique.".format(node_labels))
57575
def annotated(self):
        
        # Build up dictionary of edge annotations.
        edge_annotations = {}
        for edge in self.edges:
            if edge not in edge_annotations:
                # We annotate all edges from a given object at once.
                referrer = self._tail[edge]
                known_refs = annotated_references(referrer)
                for out_edge in self._out_edges[referrer]:
                    referent = self._head[out_edge]
                    if known_refs[referent]:
                        annotation = known_refs[referent].pop()
                    else:
                        annotation = None
                    edge_annotations[out_edge] = annotation

        annotated_vertices = [
            AnnotatedVertex(
                id=id(vertex),
                annotation=object_annotation(vertex),
            )
            for vertex in self.vertices
        ]

        annotated_edges = [
            AnnotatedEdge(
                id=edge,
                annotation=edge_annotations[edge],
                head=id(self._head[edge]),
                tail=id(self._tail[edge]),
            )
            for edge in self.edges
        ]

        return AnnotatedGraph(
            vertices=annotated_vertices,
            edges=annotated_edges,
        )
977133
def label_tree(n,lookup):
    '''
    '''
    if len(n["children"]) == 0:
        leaves = [lookup[n["node_id"]]]
    else:
        leaves = reduce(lambda ls, c: ls + label_tree(c,lookup), n["children"], [])
    del n["node_id"]
    n["name"] = name = "|||".join(sorted(map(str, leaves)))
    return leaves
1338468
def fetchall_labels(ont):
    
    logging.info("fetching rdfs:labels for: "+ont)
    namedGraph = get_named_graph(ont)
    queryBody = querybody_label()
    query = """
    SELECT * WHERE {{
    GRAPH <{g}>  {q}
    }}
    """.format(q=queryBody, g=namedGraph)
    bindings = run_sparql(query)
    rows = [(r['c']['value'], r['l']['value']) for r in bindings]
    return rows
1082300
def _annotate(
        cls,
        item,
        timestamp,
        stack_depth
    ):
        
        item.timestamp = timestamp
        item.machine = machine_metadata
        item.template = strings.limit(item.template, 10000)

        item.format = strings.limit(item.format, 10000)
        if item.format == None:
            format = text_type(item)
        else:
            format = item.format.replace("{{", "{{params.")
        if not format.startswith(CR) and format.find(CR) > -1:
            format = CR + format

        if cls.trace:
            log_format = item.format = "{{machine.name}} (pid {{machine.pid}}) - {{timestamp|datetime}} - {{thread.name}} - \"{{location.file}}:{{location.line}}\" - ({{location.method}}) - " + format
            f = sys._getframe(stack_depth + 1)
            item.location = {
                "line": f.f_lineno,
                "file": text_type(f.f_code.co_filename),
                "method": text_type(f.f_code.co_name)
            }
            thread = _Thread.current()
            item.thread = {"name": thread.name, "id": thread.id}
        else:
            log_format = item.format = "{{timestamp|datetime}} - " + format

        cls.main_log.write(log_format, item.__data__())
1203623
function labels (configName, callback) {

    if (callback) {
        return get(configName).schema.statics.getLabels(callback);
    }

    return get(configName).schema.statics.getLabels();
}
1160936
def _select_labels(self, segmentation, labels=None):
        

        logger.debug("select_labels() started with labels={}".format(labels))
        if self.slab is not None and labels is not None:
            segmentation_out = select_labels(segmentation, labels, slab=self.slab)
        else:
            logger.warning("Nothing found for labels " + str(labels))
            un = np.unique(segmentation)
            if len(un) < 2:
                logger.error("Just one label found in input segmenation")
            segmentation_out = (segmentation > un[0]).astype(segmentation.dtype)
        return segmentation_out
133146
def optimize(initial_memory):
    
    global BLOCKS
    global PROC_COUNTER

    LABELS.clear()
    JUMP_LABELS.clear()
    del MEMORY[:]
    PROC_COUNTER = 0

    cleanupmem(initial_memory)
    if OPTIONS.optimization.value <= 2:
        return '\n'.join(x for x in initial_memory if not RE_PRAGMA.match(x))

    optimize_init()
    bb = BasicBlock(initial_memory)
    cleanup_local_labels(bb)
    initialize_memory(bb)

    BLOCKS = basic_blocks = get_basic_blocks(bb)  # 1st partition the Basic Blocks

    for x in basic_blocks:
        x.clean_up_comes_from()
        x.clean_up_goes_to()

    for x in basic_blocks:
        x.update_goes_and_comes()

    LABELS['*START*'].basic_block.add_goes_to(basic_blocks[0])
    LABELS['*START*'].basic_block.next = basic_blocks[0]

    basic_blocks[0].prev = LABELS['*START*'].basic_block
    LABELS[END_PROGRAM_LABEL].basic_block.add_goes_to(LABELS['*__END_PROGRAM*'].basic_block)

    for x in basic_blocks:
        x.optimize()

    for x in basic_blocks:
        if x.comes_from == [] and len([y for y in JUMP_LABELS if x is LABELS[y].basic_block]):
            x.ignored = True

    return '\n'.join([y for y in flatten_list([x.asm for x in basic_blocks if not x.ignored])
                      if not RE_PRAGMA.match(y)])