Get boxes and lines using labels as id.
969590
def get_boxes_and_lines(ax, labels):
    """"""
    labels_u, labels_u_line = get_labels(labels)
    boxes = ax.findobj(mpl.text.Annotation)
    lines = ax.findobj(mpl.lines.Line2D)
    lineid_boxes = []
    lineid_lines = []

    for box in boxes:
        l = box.get_label()
        try:
            loc = labels_u.index(l)
        except ValueError:
            # this box is either one not added by lineidplot or has no label.
            continue
        lineid_boxes.append(box)

    for line in lines:
        l = line.get_label()
        try:
            loc = labels_u_line.index(l)
        except ValueError:
            # this line is either one not added by lineidplot or has no label.
            continue
        lineid_lines.append(line)

    return lineid_boxes, lineid_lines
1201039
def get_labels(cs):
    """"""
    records = []
    for c in cs:
        records.extend(c.get('labels', []))
    return records
1209038
def _label_desc(self, label, desc, label_color=''):
        '''  '''
        return self.BRIGHT +  label_color + label + self.RESET + desc
1039009
def get_labels(filename, logger=None):
    
    labeldict = {}
    if filename is not None:
        if logger:
            logger.info("Reading labels from %s", filename)
        with open(filename, "r") as ifh:
            count = 0
            for line in ifh.readlines():
                count += 1
                try:
                    key, label = line.strip().split("\t")
                except ValueError:
                    if logger:
                        logger.warning("Problem with class file: %s", filename)
                        logger.warning("%d: %s", (count, line.strip()))
                        logger.warning("(skipping line)")
                    continue
                else:
                    labeldict[key] = label
    return labeldict
321217
def _parse_data_desc(data_names, label_names, data_shapes, label_shapes):
    """"""
    data_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in data_shapes]
    _check_names_match(data_names, data_shapes, 'data', True)
    if label_shapes is not None:
        label_shapes = [x if isinstance(x, DataDesc) else DataDesc(*x) for x in label_shapes]
        _check_names_match(label_names, label_shapes, 'label', False)
    else:
        _check_names_match(label_names, [], 'label', False)
    return data_shapes, label_shapes
658009
function collectRowsByLabel(rowsByLabel) {
  const labels = [...rowsByLabel.keys()].sort();
  const rows = [];
  for (const label of labels) {
    const cells = rowsByLabel.get(label) || [];
    if (cells.length === 0) continue;
    rows.push({label, cells});
  }
  return rows;
}
551016
def label_search(self, label:str) -> List[dict]:
        ''' 
        '''
        ilx_rows = self.label2rows(self.local_degrade(label))
        if not ilx_rows:
            return None
        else:
            return ilx_rows
1252148
def _get_boxes(pos, size=None, margin=0, keep_aspect_ratio=True):
    """"""

    # Get x, y.
    pos = np.asarray(pos, dtype=np.float64)
    x, y = pos.T
    x = x[:, np.newaxis]
    y = y[:, np.newaxis]

    w, h = size if size is not None else _get_box_size(x, y, margin=margin)

    x0, y0 = x - w, y - h
    x1, y1 = x + w, y + h

    # Renormalize the whole thing by keeping the aspect ratio.
    x0min, y0min, x1max, y1max = x0.min(), y0.min(), x1.max(), y1.max()
    if not keep_aspect_ratio:
        b = (x0min, y0min, x1max, y1max)
    else:
        dx = x1max - x0min
        dy = y1max - y0min
        if dx > dy:
            b = (x0min, (y1max + y0min) / 2. - dx / 2.,
                 x1max, (y1max + y0min) / 2. + dx / 2.)
        else:
            b = ((x1max + x0min) / 2. - dy / 2., y0min,
                 (x1max + x0min) / 2. + dy / 2., y1max)
    r = Range(from_bounds=b,
              to_bounds=(-1, -1, 1, 1))
    return np.c_[r.apply(np.c_[x0, y0]), r.apply(np.c_[x1, y1])]
337135
def _get_indices(self, element, labels='all', mode='or'):
        
        """
        # Parse and validate all input values.
        element = self._parse_element(element, single=True)
        labels = self._parse_labels(labels=labels, element=element)
        if element+'.all' not in self.keys():
            raise Exception('Cannot proceed without {}.all'.format(element))

        # Begin computing label array
        if mode in ['or', 'any', 'union']:
            union = sp.zeros_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                union = union + self[element+'.'+item.split('.')[-1]]
            ind = union
        elif mode in ['and', 'all', 'intersection']:
            intersect = sp.ones_like(self[element+'.all'], dtype=bool)
            for item in labels:  # Iterate over labels and collect all indices
                intersect = intersect*self[element+'.'+item.split('.')[-1]]
            ind = intersect
        elif mode in ['xor', 'exclusive_or']:
            xor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xor = xor + sp.int8(info)
            ind = (xor == 1)
        elif mode in ['nor', 'not', 'none']:
            nor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nor = nor + sp.int8(info)
            ind = (nor == 0)
        elif mode in ['nand']:
            nand = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                nand = nand + sp.int8(info)
            ind = (nand < len(labels)) * (nand > 0)
        elif mode in ['xnor', 'nxor']:
            xnor = sp.zeros_like(self[element+'.all'], dtype=int)
            for item in labels:  # Iterate over labels and collect all indices
                info = self[element+'.'+item.split('.')[-1]]
                xnor = xnor + sp.int8(info)
            ind = (xnor > 1)
        else:
            raise Exception('Unsupported mode: '+mode)
        # Extract indices from boolean mask
        ind = sp.where(ind)[0]
        ind = ind.astype(dtype=int)
        return ind
504579
def labels_to_indices(self, labels: Sequence[str]) -> List[int]:
        

        return [self.LABEL_TO_INDEX[label] for label in labels]
1369001
def _label(self, line):
        '''

        '''
        label = self._setup('LABEL', line)
        self.labels += [ label ]
1115681
def to_array(self):
        """"""
        dt = np.dtype(list(zip(self.labels, (c.dtype for c in self.columns))))
        arr = np.empty_like(self.columns[0], dt)
        for label in self.labels:
            arr[label] = self[label]
        return arr
817169
def _load_image_labels(self):
        
        temp = []

        # load ground-truth from xml annotations
        for idx in self.image_set_index:
            label_file = self._label_path_from_index(idx)
            tree = ET.parse(label_file)
            root = tree.getroot()
            size = root.find('size')
            width = float(size.find('width').text)
            height = float(size.find('height').text)
            label = []

            for obj in root.iter('object'):
                difficult = int(obj.find('difficult').text)
                # if not self.config['use_difficult'] and difficult == 1:
                #     continue
                cls_name = obj.find('name').text
                if cls_name not in self.classes:
                    continue
                cls_id = self.classes.index(cls_name)
                xml_box = obj.find('bndbox')
                xmin = float(xml_box.find('xmin').text) / width
                ymin = float(xml_box.find('ymin').text) / height
                xmax = float(xml_box.find('xmax').text) / width
                ymax = float(xml_box.find('ymax').text) / height
                label.append([cls_id, xmin, ymin, xmax, ymax, difficult])
            temp.append(np.array(label))
        return temp
450748
def labels(self):
        
        return [self._labels.get(value) or text.pretty(key)
                for key, value in sorted(self.items(), key=lambda x: x[1])]
353043
def _get_x_label(self, i):
        """"""
        if not self.x_labels or not self._y_labels or len(self._y_labels) <= i:
            return
        return self._y_labels[i][0]
1072029
def _format_id(ns, id):
    """"""
    label = '%s:%s' % (ns, id)
    label = label.replace(' ', '_')
    url = get_identifiers_url(ns, id)
    return (label, url)
576105
def _label_from_list(self, labels:Iterator, label_cls:Callable=None, from_item_lists:bool=False, **kwargs)->'LabelList':
        ""
        if not from_item_lists:
            raise Exception("Your data isn't split, if you don't want a validation set, please use `split_none`.")
        labels = array(labels, dtype=object)
        label_cls = self.get_label_cls(labels, label_cls=label_cls, **kwargs)
        y = label_cls(labels, path=self.path, **kwargs)
        res = self._label_list(x=self, y=y)
        return res