True_Negative / (True_Negative + False_Positive)
541360
def get_specificity(self, scalar=None):
        """"""
        if ((not self._scalar_stats and not scalar and self._num_classes > 2) or
                ((scalar is False or self._scalar_stats is False) and self._num_classes > 1)):
            spec = PrettyDict()
            for pos_label in self.columns:
                neg_labels = [label for label in self.columns if label != pos_label]
                tn = sum(self[label][label] for label in neg_labels)
                # fp = self[pos_label][neg_labels].sum()
                fp = self.loc[neg_labels].sum()[pos_label]
                assert(self[pos_label][neg_labels].sum() == fp)
                spec[pos_label] = float(tn) / (tn + fp)
            return pd.Series(spec)
        return self._binary_specificity
830968
def str_to_bool(val):
    """"""
    val = str(val).lower().strip()
    if val in ("1", "true", "on", "yes"):
        return True
    elif val in ("0", "false", "off", "no"):
        return False
    raise ValueError(
        "Invalid value '{}'"
        "(expected '1', '0', 'true', 'false', 'on', 'off', 'yes', 'no').".format(val)
    )
720070
function defaultComp(a,b) {
		var as = '' + a,
			bs = '' + b;

		if (as < bs) {
			return -1;
		} else if (as > bs) {
			return 1;
		} else {
			return 0;
		}
	}
106333
private Number readReal(long prev, boolean negative) throws IOException {
		StringBuilder b = new StringBuilder(prev + ".");
		boolean exponent = false;
		boolean expsign = false;
		do {
			currentCharacter = r.read();
			if (currentCharacter >= '0' && currentCharacter <= '9') {
				b.append((char)currentCharacter);
			} else if (currentCharacter == 'e' || currentCharacter == 'E') {
				if (exponent) {
					break;
				}
				b.append((char)currentCharacter);
				exponent = true;
			} else if (currentCharacter == '-' || currentCharacter == '+') {
				if (expsign) {
					break;
				}
				b.append((char)currentCharacter);
				expsign = true;
			} else {
				break;
			}
		} while (currentCharacter >= 0);
		
		double result = Double.parseDouble(b.toString());
		return negative ? -result : result;
	}
718184
def nonnegative_float(s):
    
    err_msg = "must be either positive or zero, not %r" % s
    try:
        value = float(s)
    except ValueError:
        raise argparse.ArgumentTypeError(err_msg)
    if value < 0:
        raise argparse.ArgumentTypeError(err_msg)
    return value
14820
Expr ternary() {
		Expr cond = or();
		if (peek().sym == Sym.QUESTION) {
			move();
			Expr exprOne = expr();
			match(Sym.COLON);
			return new Ternary(cond, exprOne, expr(), location);
		}
		return cond;
	}
539140
def cast_to_number_or_bool(inputstr):
    
    if inputstr.strip().lower() == "true":
        return True
    elif inputstr.strip().lower() == "false":
        return False
    try:
        return int(inputstr)
    except ValueError:
        try:
            return float(inputstr)
        except ValueError:
            return inputstr
1327979
def boolean(value):
    
    if isinstance(value, bool):
        return value

    if value == "":
        return False

    return strtobool(value)
914946
def _parse_bool(value):
    """"""
    if isinstance(value, bool):
        return value

    elif isinstance(value, str):
        if value == 'True':
            return True
        elif value == 'False':
            return False

    raise Exception("Value %s is not boolean." % value)
262581
def conditional( a, b )
      if a.is_a?( Proc ) and b.is_a?( Proc )
        conditional a.call, b.call
      else
        GCCValue.new @function, "( #{self} ) ? ( #{a} ) : ( #{b} )"
      end
    end
1327237
def parse_bool(value):
    
    value = str(value).lower()
    if value in ('on', 'true', 'yes', '1'):
        return True
    if value in ('off', 'false', 'no', '0'):
        return False
1207078
def bool_input(message):
    '''
    
    '''

    while True:
        suffix = ' (true or false): '
        inp = input(message + suffix)
        if inp.lower() == 'true':
            return True
        elif inp.lower() == 'false':
            return False
        else:
            print(colored('Must be either true or false, try again!', 'red'))
1374424
def _isbool(string):
    
    return isinstance(string, _bool_type) or\
        (isinstance(string, (_binary_type, _text_type))
         and
         string in ("True", "False"))
1221200
def convert_bool(string):
    
    if string == 'True':
        return True, True
    elif string == 'False':
        return True, False
    else:
        return False, False
1104417
def validate_bool(b):
    """"""
    if isinstance(b, six.string_types):
        b = b.lower()
    if b in ('t', 'y', 'yes', 'on', 'true', '1', 1, True):
        return True
    elif b in ('f', 'n', 'no', 'off', 'false', '0', 0, False):
        return False
    else:
        raise ValueError('Could not convert "%s" to boolean' % b)
26987
def count_sign(values, min_value):
    
    positive_count = 0
    negative_count = 0
    for value in values:
        if value > min_value:
            positive_count += 1
        elif value < -min_value:
            negative_count += 1
    return positive_count, negative_count
1284416
def to_bool(value):
    '''
    
    '''
    if isinstance(value, bool):
        return value
    elif isinstance(value, basestring):
        return value.lower() == 'true' or value.lower() == 't'
    elif isinstance(value, int):
        return value > 0
    else:
        return False