import warnings


def get_config(default, config=None, warn=1):
    """
    Return a dictionary containing default configuration settings and any
    settings that the user has specified. The user settings will override the
    default settings.
    Args:
        default(dict) : A dictionary of default configuration settings.
        config(dict) : A dictionary of user-specified configuration settings.
        warn: Issue a warning if `config` contains an unknown key (not found in
            `default`).
    Returns:
        dict : User-specified configuration supplemented with default settings
            for field the user has not specified.
    """

    config_out = {}
    # Set defaults
    for key in default:
        config_out[key] = default[key]

    if not config:
        return config_out

    for key in config:
        if key not in default and warn:
            warnings.warn('Unknown option: %s in `config`' % key)
            # assert 0

    # Override defaults
    for key in config:
        config_out[key] = config[key]

    return config_out