convert string to int or float.
19319
def covstr(s):
  
  try:
    ret = int(s)
  except ValueError:
    ret = float(s)
  return ret
612152
def strings_to_integers(strings: Iterable[str]) -> Iterable[int]:
    
    return strings_to_(strings, lambda x: int(float(x)))
1103859
def _cast_float(self, value):
        """"""
        try:
            return float(value)
        except ValueError:
            msg.err("Cannot convert {} to float for line {}.".format(value, self.identifier))
            exit(1)
169841
def str2int(self, str_value):
    """"""
    str_value = tf.compat.as_text(str_value)
    if self._str2int:
      return self._str2int[str_value]

    # No names provided, try to integerize
    failed_parse = False
    try:
      int_value = int(str_value)
    except ValueError:
      failed_parse = True
    if failed_parse or not 0 <= int_value < self._num_classes:
      raise ValueError("Invalid string class label %s" % str_value)
    return int_value
535618
def convert_string(string):
    
    if is_int(string):
        return int(string)
    elif is_float(string):
        return float(string)
    elif convert_bool(string)[0]:
        return convert_bool(string)[1]
    elif string == 'None':
        return None
    else:
        return string
67072
def to_int(value: Any) -> int:
        

        if isinstance(value, (bool, int)):
            return int(value)
        return int(str(value))
773417
def __to_float(val, digits):
    """"""
    try:
        return round(float(val), digits)
    except (ValueError, TypeError):
        return float(0)
161562
def cast_int(x):
    
    try:
        x = int(x)
    except ValueError:
        try:
            x = x.strip()
        except AttributeError as e:
            logger_misc.warn("parse_str: AttributeError: String not number or word, {}, {}".format(x, e))
    return x
1244641
def safe_int(string, default=None):
    
    value = safe_float(string, default)
    if value is not None:
        value = int(value)
    return value
377102
def convert_to_int(value):
    
    if not value:
        return None

    # Apart from numbers also accept values that end with px
    if isinstance(value, str):
        value = value.strip(' px')

    try:
        return int(value)
    except (TypeError, ValueError):
        return None
1028200
def str2ints(self, str_value):
    """"""
    if not self._encoder:
      raise ValueError(
          "Text.str2ints is not available because encoder hasn't been defined.")
    return self._encoder.encode(str_value)
196885
def _number(text):
    '''
    
    '''
    if text.isdigit():
        return int(text)
    try:
        return float(text)
    except ValueError:
        return text
787080
public Float convertStringToFloat(String value) {
        Float result;
        try {
            result = Float.valueOf(value);
        } catch (NumberFormatException e) {
            result = DEFAULT_FLOAT_VALUE;
        }
        return result;
    }
163676
def __try_parse_number(self, string):
        """"""
        try:
            return int(string)
        except ValueError:
            try:
                return float(string)
            except ValueError:
                return False
376298
protected Number parseFloat(String string) throws ParseException {
		try {
			return Double.valueOf(string);
		} catch (NumberFormatException e) {
			fail(FLOAT);
			return null;
		}
	}
1226244
def float_format(self, value):
        """"""
        if isinstance(value, str):
            # Duck-test the format string; raise ValueError on fail
            '{0:{1}}'.format(1.23, value)

            self._float_format = value
        else:
            raise TypeError('Floating point format code must be a string.')
1049790
def parse_float(float_str):
    """"""
    factor = __get_factor(float_str)
    if factor != 1:
        float_str = float_str[:-1]

    try:
        return float(float_str.replace(',', '')) * factor
    except ValueError:
        return None