Static helper method to convert INCAR parameters to proper types, e.g.,
        integers, floats, lists, etc.

        Args:
            key: INCAR parameter key
            val: Actual value of INCAR parameter.
484826
def proc_val(key, val):
        
        list_keys = ("LDAUU", "LDAUL", "LDAUJ", "MAGMOM", "DIPOL",
                     "LANGEVIN_GAMMA", "QUAD_EFG", "EINT")
        bool_keys = ("LDAU", "LWAVE", "LSCALU", "LCHARG", "LPLANE", "LUSE_VDW",
                     "LHFCALC", "ADDGRID", "LSORBIT", "LNONCOLLINEAR")
        float_keys = ("EDIFF", "SIGMA", "TIME", "ENCUTFOCK", "HFSCREEN",
                      "POTIM", "EDIFFG", "AGGAC", "PARAM1", "PARAM2")
        int_keys = ("NSW", "NBANDS", "NELMIN", "ISIF", "IBRION", "ISPIN",
                    "ICHARG", "NELM", "ISMEAR", "NPAR", "LDAUPRINT", "LMAXMIX",
                    "ENCUT", "NSIM", "NKRED", "NUPDOWN", "ISPIND", "LDAUTYPE",
                    "IVDW")

        def smart_int_or_float(numstr):
            if numstr.find(".") != -1 or numstr.lower().find("e") != -1:
                return float(numstr)
            else:
                return int(numstr)

        try:
            if key in list_keys:
                output = []
                toks = re.findall(
                    r"(-?\d+\.?\d*)\*?(-?\d+\.?\d*)?\*?(-?\d+\.?\d*)?", val)
                for tok in toks:
                    if tok[2] and "3" in tok[0]:
                        output.extend(
                            [smart_int_or_float(tok[2])] * int(tok[0])
                            * int(tok[1]))
                    elif tok[1]:
                        output.extend([smart_int_or_float(tok[1])] *
                                      int(tok[0]))
                    else:
                        output.append(smart_int_or_float(tok[0]))
                return output
            if key in bool_keys:
                m = re.match(r"^\.?([T|F|t|f])[A-Za-z]*\.?", val)
                if m:
                    if m.group(1) == "T" or m.group(1) == "t":
                        return True
                    else:
                        return False
                raise ValueError(key + " should be a boolean type!")

            if key in float_keys:
                return float(re.search(r"^-?\d*\.?\d*[e|E]?-?\d*", val).group(0))

            if key in int_keys:
                return int(re.match(r"^-?[0-9]+", val).group(0))

        except ValueError:
            pass

        # Not in standard keys. We will try a hierarchy of conversions.
        try:
            val = int(val)
            return val
        except ValueError:
            pass

        try:
            val = float(val)
            return val
        except ValueError:
            pass

        if "true" in val.lower():
            return True

        if "false" in val.lower():
            return False

        return val.strip().capitalize()
1083724
def translate(cls, val):
        """"""
        if val is None:
            return cls.translate_none(val)
        elif isinstance(val, string_types):
            return cls.translate_str(val)
        # Needs to be before integer checks
        elif isinstance(val, bool):
            return cls.translate_bool(val)
        elif isinstance(val, integer_types):
            return cls.translate_int(val)
        elif isinstance(val, float):
            return cls.translate_float(val)
        elif isinstance(val, dict):
            return cls.translate_dict(val)
        elif isinstance(val, list):
            return cls.translate_list(val)
        # Use this generic translation as a last resort
        return cls.translate_escaped_str(val)
539802
def property_value_post_conversion(val, type_info)
      case type_info.flattened_tag
      when :ghash
        GLib::HashTable.from type_info.element_type, val
      when :glist
        GLib::List.from type_info.element_type, val
      when :callback
        GirFFI::Builder.build_class(type_info.interface).wrap val
      else
        val
      end
    end
458931
def proc_val(key, val):
        

        list_type_keys = list(VALID_FEFF_TAGS)
        del list_type_keys[list_type_keys.index("ELNES")]
        del list_type_keys[list_type_keys.index("EXELFS")]
        boolean_type_keys = ()
        float_type_keys = ("S02", "EXAFS", "RPATH")

        def smart_int_or_float(numstr):
            if numstr.find(".") != -1 or numstr.lower().find("e") != -1:
                return float(numstr)
            else:
                return int(numstr)

        try:
            if key.lower() == 'cif':
                m = re.search(r"\w+.cif", val)
                return m.group(0)

            if key in list_type_keys:
                output = list()
                toks = re.split(r"\s+", val)

                for tok in toks:
                    m = re.match(r"(\d+)\*([\d\.\-\+]+)", tok)
                    if m:
                        output.extend([smart_int_or_float(m.group(2))] *
                                      int(m.group(1)))
                    else:
                        output.append(smart_int_or_float(tok))
                return output
            if key in boolean_type_keys:
                m = re.search(r"^\W+([TtFf])", val)
                if m:
                    if m.group(1) == "T" or m.group(1) == "t":
                        return True
                    else:
                        return False
                raise ValueError(key + " should be a boolean type!")

            if key in float_type_keys:
                return float(val)

        except ValueError:
            return val.capitalize()

        return val.capitalize()
824955
public ValueMap withNumberSet(String key, Set<BigDecimal> val) {
        super.put(key, val);
        return this;
    }
1052314
def map_val(dest, src, key, default=None, src_key=None):
    """"""
    if not src_key:
        src_key = key

    if src_key in src:
        dest[key] = src[src_key]
    else:
        if default is not None:
            dest[key] = default
1151984
def _to_int(self, val_str):
        """"""
        val = _integerValue_to_int(val_str)
        if val is None:
            raise ValueError(
                _format("The value-mapped {0} has an invalid integer "
                        "representation in a ValueMap entry: {1!A}",
                        self._element_str(), val_str))
        return val
1278166
def _check_key(self, key):
        
        if not len(key) == 2:
            raise TypeError('invalid key: %r' % key)
        elif key[1] not in TYPES:
            raise TypeError('invalid datatype: %s' % key[1])
730684
def _process_key_val(self, instance, key, val):
        '''
        
        '''
        if instance.check_precondition(key, val):
            combined = '{k}:{v}'.format(k=key, v=val)
            self._increment_total_stat(combined)
            self._increment_plugin_stat(
                instance.__class__.__name__,
                combined)
            instance.handle(key, val)
            self.redis_conn.delete(key)
            failkey = self._get_fail_key(key)
            if self.redis_conn.exists(failkey):
                self.redis_conn.delete(failkey)
1060402
def get(self, key, *val):
        
        data = self.get_data()
        if data is not None:
            return data.get(key, *val)
        if val:
            return val[0]
        raise KeyError(key)
950004
def value_to_int(attrib, key):
    
    val = attrib.get(key, 0)
    if isinstance(val, str):
        if val.isspace() or val == '':
            return 0
    return val
593657
function getType(key, req) {
  var val = this.getKey(key, req);
  if(val === undefined) return undefined;
  return val.rtype || TYPE_NAMES.STRING;
}
907059
def val(self, strictkey):
        
        ruamelkey = self.ruamelindex(strictkey)
        return self._select(self._pointer.val(ruamelkey, strictkey))
584400
@Override
  public Object put(String key, Object val) {
    val = val != null && val instanceof Number ? Number.class.cast(val).intValue() : val;
    return super.put(key, val);
  }
1099937
function value(val, buf, simple) {
  buf = buf || new Buffer(0);
  var type = typeof val;

  // coerce booleans to integers
  val = type === 'boolean' ? Number(val) : val;

  // treat floats as strings
  if(type === 'number' && parseInt(val) !== val) {
    val = '' + val;
  }

  // String instances are treated as simple strings
  if(val instanceof String) {
    simple = true;
    val = val.toString();
  }

  // re-evaluate type after coercion
  type = typeof val;

  if(val instanceof Buffer) {
    buf = _bst(buf, val);
  }else if(val === null) {
    buf = _nil(buf);
  }else if(Array.isArray(val)) {
    buf = _arr(buf, val);
  }else if(type === 'number'){
    buf = _int(buf, val);
  }else if(type === 'string') {
    buf = simple ? _str(buf, val) : _bst(buf, val);
  }else if(val instanceof Error) {
    buf = _err(buf, val);
  }else{
    assert(false, 'invalid encoder type: ' + type);
  }
  return buf;
}
590679
def check_key(data_object, key, cardinal=False):
    
    itype = (int, np.int32, np.int64)
    if not isinstance(key, itype + (slice, tuple, list, np.ndarray)):
        raise KeyError("Unknown key type {} for key {}".format(type(key), key))
    keys = data_object.index.values
    if cardinal and data_object._cardinal is not None:
        keys = data_object[data_object._cardinal[0]].unique()
    elif isinstance(key, itype) and key in keys:
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, itype) and key < 0:
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, itype):
        key = [key]
    elif isinstance(key, slice):
        key = list(sorted(data_object.index.values[key]))
    elif isinstance(key, (tuple, list, pd.Index)) and not np.all(k in keys for k in key):
        key = list(sorted(data_object.index.values[key]))
    return key
1115990
def get_arg_value_as_type(self, key, default=None, convert_int=False):
        

        val = self.get_query_argument(key, default)

        if isinstance(val, int):
            return val

        if val.lower() in ['true', 'yes']:
            return True

        if val.lower() in ['false', 'no']:
            return False

        return val