Check the label image for consistent labelling starting from 1.
551731
def __check_label_image(label_image):
    """"""
    encountered_indices = scipy.unique(label_image)
    expected_indices = scipy.arange(1, label_image.max() + 1)
    if not encountered_indices.size == expected_indices.size or \
       not (encountered_indices == expected_indices).all():
        raise AttributeError('The supplied label image does either not contain any regions or they are not labeled consecutively starting from 1.')
1253281
public void setLabel(String label) {

        int ix = lstSizes.indexOf(label);
        if (ix != -1) {
            setLabel(ix);
        }
    }
514111
def is_valid_mpls_labels(labels):
    
    if not isinstance(labels, (list, tuple)):
        return False

    for label in labels:
        if not is_valid_mpls_label(label):
            return False

    return True
828792
def _qteGetLabelInstance(self):
        
        # Create a label with the proper colour appearance.
        layout = self.layout()
        label = QtGui.QLabel(self)
        style = 'QLabel { background-color : white; color : blue; }'
        label.setStyleSheet(style)
        return label
1073149
def _get_labels_right(self, validate=None):
        """"""
        labels = []

        for compare_func in self.features:

            labels = labels + listify(compare_func.labels_right)

        # check requested labels (for better error messages)
        if not is_label_dataframe(labels, validate):
            error_msg = "label is not found in the dataframe"
            raise KeyError(error_msg)

        return unique(labels)
1146771
def get_image_label(name, default="not_found.png"):
    """"""
    label = QLabel()
    label.setPixmap(QPixmap(get_image_path(name, default)))
    return label
928081
def are_labels_overlapping(label1, label2):
        

        if (
                                label2.start_seconds > label1.end_seconds and
                                label2.start_seconds > label1.start_seconds and
                                label2.end_seconds > label1.start_seconds and
                                label2.end_seconds > label1.start_seconds) or (
                                label2.start_seconds < label1.start_seconds and
                                label2.end_seconds < label1.start_seconds and
                                label2.start_seconds < label1.end_seconds and
                                label2.end_seconds < label1.end_seconds):
            return False
        else:
            return True
927393
def __label_cmp(self, other):
        
        if other is None:
            return -1

        label_name = strip_accents(self.name).lower()
        other_name = strip_accents(other.name).lower()
        if label_name < other_name:
            return -1
        elif label_name == other_name:
            return 0
        else:
            return 1

        if self.get_color_str() < other.get_color_str():
            return -1
        elif self.get_color_str() == other.get_color_str():
            return 0
        else:
            return 1
1293862
def label(self, value):
        
        return self._labels.get(value) or text.pretty(self(value))
998390
function () {
            if (!this.coords.w_rs) {
                return;
            }

            this.labels.p_min = this.labels.w_min / this.coords.w_rs * 100;
            this.labels.p_max = this.labels.w_max / this.coords.w_rs * 100;
        }
740266
def labels(self, value):
        
        if value is not None:
            assert type(value) is tuple, "'{0}' attribute: '{1}' type is not 'tuple'!".format("labels", value)
            assert len(value) == 2, "'{0}' attribute: '{1}' length should be '2'!".format("labels", value)
            for index in range(len(value)):
                assert type(value[index]) is unicode, \
                    "'{0}' attribute element '{1}': '{2}' type is not 'unicode'!".format("labels", index, value)
        self.__labels = value
99901
def p_label_line_co(p):
    
    lbl = make_label(p[1], p.lineno(1))
    p[0] = make_block(lbl, p[2]) if len(p) == 3 else lbl
595981
def _has_example(self, label):
        """"""
        if label in self._raw_examples:
            return True
        else:
            for field in self.all_fields:
                dt, _ = unwrap_nullable(field.data_type)
                if not is_user_defined_type(dt) and not is_void_type(dt):
                    continue
                if label == field.name:
                    return True
            else:
                return False
725856
def validate_slice_increment(dicoms):
    
    first_image_position = numpy.array(dicoms[0].ImagePositionPatient)
    previous_image_position = numpy.array(dicoms[1].ImagePositionPatient)

    increment = first_image_position - previous_image_position
    for dicom_ in dicoms[2:]:
        current_image_position = numpy.array(dicom_.ImagePositionPatient)
        current_increment = previous_image_position - current_image_position
        if not numpy.allclose(increment, current_increment, rtol=0.05, atol=0.1):
            logger.warning('Slice increment not consistent through all slices')
            logger.warning('---------------------------------------------------------')
            logger.warning('%s %s' % (previous_image_position, increment))
            logger.warning('%s %s' % (current_image_position, current_increment))
            if 'InstanceNumber' in dicom_:
                logger.warning('Instance Number: %s' % dicom_.InstanceNumber)
            logger.warning('---------------------------------------------------------')
            raise ConversionValidationError('SLICE_INCREMENT_INCONSISTENT')
        previous_image_position = current_image_position
607915
private void updateSetsLabeled(int i1, final double a1, final double C)
    {
        final double y_i = label[i1];
        I1[i1] = a1 == 0 && y_i == 1;
        I2[i1] = a1 == C && y_i == -1;
        I3[i1] = a1 == C && y_i == 1;
        I4[i1] = a1 == 0 && y_i == -1;
    }
1065365
def _calibrate(self, data, labels):
        
        # network calibration
        classifier = defaultdict(Counter)
        for (i,j), label in zip(self._bmus, labels):
            classifier[i,j][label] += 1
        self.classifier = {}
        for ij, cnt in classifier.items():
            maxi = max(cnt.items(), key=itemgetter(1))
            nb = sum(cnt.values())
            self.classifier[ij] = maxi[0], maxi[1] / nb
211789
def _estimate_label_shape(self):
        """"""
        max_count = 0
        self.reset()
        try:
            while True:
                label, _ = self.next_sample()
                label = self._parse_label(label)
                max_count = max(max_count, label.shape[0])
        except StopIteration:
            pass
        self.reset()
        return (max_count, label.shape[1])