Raise exception (ValueError) if labels not correct
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
753991
def handle_exception(self, message, exc):
        # type: (Text, Exception) -> Any
        
        return self.handle_invalid_value(
            message     = message,
            exc_info    = True,
            context     = getattr(exc, 'context', {}),
        )
491208
def setLabel(self, value, label):
        
        if label:
            self._labels[value] = label
        else:
            self._labels.pop(value, None)
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
158120
def p_error_raise(p):
    
    q = make_number(1, lineno=p.lineno(2))
    r = make_binary(p.lineno(1), 'MINUS',
                    make_typecast(TYPE.ubyte, p[2], p.lineno(1)), q,
                    lambda x, y: x - y)
    p[0] = make_sentence('ERROR', r)
1244762
def check_label_shapes(labels, preds, shape=0):
    """"""

    if shape == 0:
        label_shape, pred_shape = len(labels), len(preds)
    else:
        label_shape, pred_shape = labels.shape, preds.shape

    if label_shape != pred_shape:
        raise ValueError("Shape of labels {} does not match shape of "
                         "predictions {}".format(label_shape, pred_shape))
1227363
def AddLabel(self, label):
    
    if not isinstance(label, py2to3.STRING_TYPES):
      raise TypeError('label is not a string type. Is {0:s}'.format(
          type(label)))
    if not self._VALID_LABEL_REGEX.match(label):
      raise ValueError((
          'Unsupported label: "{0:s}". A label must only consist of '
          'alphanumeric characters or underscores.').format(label))

    if label not in self.labels:
      self.labels.append(label)
34863
def _raise_exception(self, eobj, edata=None):
        """"""
        _, _, tbobj = sys.exc_info()
        if edata:
            emsg = self._format_msg(eobj["msg"], edata)
            _rwtb(eobj["type"], emsg, tbobj)
        else:
            _rwtb(eobj["type"], eobj["msg"], tbobj)
155314
private void checkLabels(boolean forGenerative, String... label)
	{
		for (int i = 0; i < (forGenerative ? label.length - 1 : label.length); i++)
		{
			if (!hasLabel(label[i])) throw new IllegalArgumentException(
				"Label neither found, nor generated: " + label[i]);
		}
	}
210072
def _raise_error_iface(iface, option, expected):
    '''
    
    '''
    msg = _error_msg_iface(iface, option, expected)
    log.error(msg)
    raise AttributeError(msg)
1284947
def assert_or_raise(stmt: bool, exception: Exception,
                    *exception_args, **exception_kwargs) -> None:
  
  if not stmt:
    raise exception(*exception_args, **exception_kwargs)
656525
def try_and_error(*funcs):
    """"""
    def validate(value):
        exc = None
        for func in funcs:
            try:
                return func(value)
            except (ValueError, TypeError) as e:
                exc = e
        raise exc
    return validate
990362
def errorstr(self, space, use_repr=False):
        ""
        w_value = self.get_w_value(space)
        if space is None:
            # this part NOT_RPYTHON
            exc_typename = str(self.w_type)
            exc_value = str(w_value)
        else:
            w = space.wrap
            if space.is_w(space.type(self.w_type), space.w_text):
                exc_typename = space.str_w(self.w_type)
            else:
                exc_typename = space.str_w(
                    space.getattr(self.w_type, w('__name__')))
            if space.is_w(w_value, space.w_None):
                exc_value = ""
            else:
                try:
                    if use_repr:
                        exc_value = space.str_w(space.repr(w_value))
                    else:
                        exc_value = space.str_w(space.str(w_value))
                except OperationError:
                    # oups, cannot __str__ the exception object
                    exc_value = "<oups, exception object itself cannot be str'd>"
        if not exc_value:
            return exc_typename
        else:
            return '%s: %s' % (exc_typename, exc_value)
637323
def labels(self, values):
        """"""
        if isinstance(values, dict):
            if self.__data is not None and len(self.__data) != len(values):
                raise ValueError(
                    'number of samples do not match the previously assigned data')
            elif set(self.keys) != set(list(values)):
                raise ValueError('sample ids do not match the previously assigned ids.')
            else:
                self.__labels = values
        else:
            raise ValueError('labels input must be a dictionary!')
45600
def check_labels(self):
        
        for entry in self.labels:
            self.check_is_declared(entry.name, entry.lineno, CLASS.label)
810
def _check_valid_label(self, label):
        """"""
        if len(label.shape) != 2 or label.shape[1] < 5:
            msg = "Label with shape (1+, 5+) required, %s received." % str(label)
            raise RuntimeError(msg)
        valid_label = np.where(np.logical_and(label[:, 0] >= 0, label[:, 3] > label[:, 1],
                                              label[:, 4] > label[:, 2]))[0]
        if valid_label.size < 1:
            raise RuntimeError('Invalid label occurs.')
533650
def RaiseIfNotErrorSuccess(result, func = None, arguments = ()):
    
    if result != ERROR_SUCCESS:
        raise ctypes.WinError(result)
    return result