def add_params_to_parser(parser, params):
    assert isinstance(parser, ArgumentParser)
    assert isinstance(params, dict)

    def get_type_details(v):
        for t in (int, float, str):
            try:
                value = t(v)
                return (t, value)
            except ValueError:
                continue
    params.pop('', None)
    for (param, value) in params.items():
        (type, type_value) = get_type_details(value)
        parser.add_argument(('--%s' % param), type=type, default=type_value)
    return parser
def add_params_to_parser(parser, params):
    assert isinstance(parser, ArgumentParser)
    assert isinstance(params, dict)

    def get_type_details(v):
        for t in (int, float, str):
            try:
                value = t(v)
                return (t, value)
            except ValueError:
                continue
    params.pop(, None)
    for (param, value) in params.items():
        (type, type_value) = get_type_details(value)
        parser.add_argument(('--%s' % param), type=type, default=type_value)
    return parser