Yields `(raw_value, label)` pairs for all acceptable choices.
491324
def options(self):
        '''
        
        '''
        conv = self.conv
        for python_value, label in self.choices:
            yield conv.from_python(python_value), label
1333278
def enrich_value(value)
      return value unless value.is_a?(ActiveTriples::Resource) &&
                          value.respond_to?(:providedLabel)

      construct_results(value)
    end
626468
def get_fields(self, strip_labels=False):
        
        if strip_labels:
            return [
                f[0] if type(f) in (tuple, list) else f for f in self.fields
            ]
        return self.fields
436181
def a_list(label=None, kwargs=None, attributes=None):
    
    result = ['label=%s' % quote(label)] if label is not None else []
    if kwargs:
        items = ['%s=%s' % (quote(k), quote(v))
            for k, v in tools.mapping_items(kwargs) if v is not None]
        result.extend(items)
    if attributes:
        if hasattr(attributes, 'items'):
            attributes = tools.mapping_items(attributes)
        items = ['%s=%s' % (quote(k), quote(v))
            for k, v in attributes if v is not None]
        result.extend(items)
    return ' '.join(result)
698959
def label_set(self):
        """"""
        label_set = list()
        for class_ in self.class_set:
            samples_in_class = self.sample_ids_in_class(class_)
            label_set.append(self.labels[samples_in_class[0]])

        return label_set
406453
def selections(self):
        ""
        for key, value in self.pairs:
            if '__' in key:
                column, lookup = key.rsplit('__', 1)
            else:
                column = key
                lookup = 'exact'
            yield column, lookup, value
507145
def _label_names_correct(self, labels):
        """"""

        for k, v in labels.items():
            # Check reserved labels
            if k in RESTRICTED_LABELS_NAMES:
                raise ValueError("Labels not correct")

            # Check prefixes
            if any(k.startswith(i) for i in RESTRICTED_LABELS_PREFIXES):
                raise ValueError("Labels not correct")

        return True
625907
def process_error_labels(value):
        

        observed_error_labels = {}
        for error in value.get('errors', []):
            label = error.get('label', 'error')

            if label not in observed_error_labels:
                observed_error_labels[label] = 0
            observed_error_labels[label] += 1

            if observed_error_labels[label] > 1:
                error['label'] = label + '_' + str(observed_error_labels[label])

            # append "_1" to first error label that has a duplicate
            if observed_error_labels[label] == 2:
                for error1 in value.get('errors', []):
                    error1_label = error1.get('label', 'error')
                    if error1_label == label:
                        error1['label'] = label + "_1"
                        break
468405
def preprocess(ops, nlp, rows, get_ids):
    """"""
    Xs = []
    ys = []
    for (text1, text2), label in rows:
        Xs.append((get_ids([nlp(text1)])[0], get_ids([nlp(text2)])[0]))
        ys.append(label)
    return Xs, ops.asarray(ys, dtype="float32")
718499
def wrap(self, values):
        
        if isinstance(values, Value):
            return values
        cols = dict([(L, []) for L in self.labels])
        try:
            # unzip list of dict
            for V in values:
                for L in self.labels:
                    try:
                        cols[L].append(V[L])
                    except (IndexError, KeyError):
                        pass
            # allow omit empty columns
            for L in self.labels:
                V = cols[L]
                if len(V) == 0:
                    del cols[L]

            try:
                return self.Value(self.type, {
                    'labels': self.labels,
                    'value': cols,
                })
            except:
                _log.error("Failed to encode '%s' with %s", cols, self.labels)
                raise
        except:
            _log.exception("Failed to wrap: %s", values)
            raise
1130829
def iter_options(grouped_choices, cutoff=None, cutoff_text=None):
    
    class StartOptionGroup(object):
        start_option_group = True
        end_option_group = False

        def __init__(self, label):
            self.label = label

    class EndOptionGroup(object):
        start_option_group = False
        end_option_group = True

    class Option(object):
        start_option_group = False
        end_option_group = False

        def __init__(self, value, display_text, disabled=False):
            self.value = value
            self.display_text = display_text
            self.disabled = disabled

    count = 0

    for key, value in grouped_choices.items():
        if cutoff and count >= cutoff:
            break

        if isinstance(value, dict):
            yield StartOptionGroup(label=key)
            for sub_key, sub_value in value.items():
                if cutoff and count >= cutoff:
                    break
                yield Option(value=sub_key, display_text=sub_value)
                count += 1
            yield EndOptionGroup()
        else:
            yield Option(value=key, display_text=value)
            count += 1

    if cutoff and count >= cutoff and cutoff_text:
        cutoff_text = cutoff_text.format(count=cutoff)
        yield Option(value='n/a', display_text=cutoff_text, disabled=True)
712687
def labels(self):
        """"""
        return tuple(_Label(label.get('id'), label.get('color'), label.text) for label
                     in self.root.iter('label'))
1297784
def return_attr(self, attr, labels=None):
        
        all_labels = self.return_label()

        if labels is None:
            labels = all_labels

        all_attr = []
        for one_label in labels:
            idx = all_labels.index(one_label)
            try:
                all_attr.append(self.chan[idx].attr[attr])
            except KeyError:
                possible_attr = ', '.join(self.chan[idx].attr.keys())
                lg.debug('key "{}" not found, '.format(attr) +
                         'possible keys are {}'.format(possible_attr))
                all_attr.append(None)

        return all_attr
70407
def _generate_dom_attrs(attrs, allow_no_value=True):
    
    for attr in iterate_items(attrs):
        if isinstance(attr, basestring):
            attr = (attr, True)
        key, value = attr
        if value is None:
            continue
        if value is True and not allow_no_value:
            value = key  # E.g. <option checked="true" />
        if value is True:
            yield True  # E.g. <option checked />
        else:
            yield '%s="%s"' % (key, value.replace('"', '\\"'))
956695
def parse_labels(result):
    '''
    '''

    if "data" in result:
        labels = result['data']['attributes'].get('labels') or {}

    elif 'attributes' in result:
        labels = result['attributes'].get('labels') or {}

    # If labels included, try parsing to json

    try:
        labels = jsonp.loads(labels)
    except:
        pass

    if "data" in result:
        result['data']['attributes']['labels'] = labels
    else:
        result['attributes']['labels'] = labels

    return result
689270
def _make_options(x):
    
    # Check if x is a mapping of labels to values
    if isinstance(x, Mapping):
        import warnings
        warnings.warn("Support for mapping types has been deprecated and will be dropped in a future release.", DeprecationWarning)
        return tuple((unicode_type(k), v) for k, v in x.items())

    # only iterate once through the options.
    xlist = tuple(x)

    # Check if x is an iterable of (label, value) pairs
    if all((isinstance(i, (list, tuple)) and len(i) == 2) for i in xlist):
        return tuple((unicode_type(k), v) for k, v in xlist)

    # Otherwise, assume x is an iterable of values
    return tuple((unicode_type(i), i) for i in xlist)
72890
private List<String> yield(List<String> labels) {
        labels.add(label);
        for (Tree t : children()) {
            labels.addAll(t.yield());
        }
        return labels;
    }