def cast(input_data, fields):
    """Checks expected type in input data values, strips affixes and casts

    """
    for (key, value) in input_data.items():
        if (
                (fields[key]['optype'] == 'numeric' and
                 isinstance(value, basestring)) or
                (fields[key]['optype'] != 'numeric' and
                 not isinstance(value, basestring))):
            try:
                if fields[key]['optype'] == 'numeric':
                    value = strip_affixes(value, fields[key])
                input_data.update({key:
                                   map_type(fields[key]
                                            ['optype'])(value)})
            except __HOLE__:
                raise ValueError(u"Mismatch input data type in field "
                                 u"\"%s\" for value %s." %
                                 (fields[key]['name'],
                                  value))
dataset/ETHPy150Open bigmlcom/python/bigml/util.py/cast