def downcast(var_specs):
    numeric_types = []

    #grab all the numeric types associated with a variables.
    for var in var_specs:
        if hasattr(var,'numeric_type'):
            numeric_types.append(var.numeric_type)

    # if arrays are present, but none of them are double precision,
    # make all numeric types float or complex(float)
    if (('f' in numeric_types or 'F' in numeric_types) and not (
            'd' in numeric_types or 'D' in numeric_types)):
        for var in var_specs:
            if hasattr(var,'numeric_type'):
                if issubclass(var.numeric_type, complex):
                    var.numeric_type = 'F'
                elif issubclass(var.numeric_type, float):
                    var.numeric_type = 'f'
    return var_specs
Cast python scalars down to most common type of
dataset/ETHPy150Open scipy/scipy/scipy/weave/ext_tools.py/downcast