def str_to_list(string, delim=',', type='float'):
    """ Convert a str (that originated from a list) back
    to a list of floats."""

    if string[0] in ('[', '(') and string[-1] in (']', ')'):
        string = string[1:-1]
    if type == 'float':
        lst = [float(num) for num in string.split(delim)]
    elif type == 'int':
        lst = [int(num) for num in string.split(delim)]
    else:
        raise ValueError('type {} not recognized'.format(type))

    return lst