Ejemplo n.º 1
0
def get_run_settings(input_dict):
    """
    Validate settings from a dict of possible input.

    Performs the following actions:
    1. Normalize (apply defaults)
    2. Validate against the schema

    Parameters
    ----------
    input_dict : dict
        Dictionary of input settings

    Returns
    -------
    dict
        Validated run settings

    Raises
    ------
    ValueError
    """
    run_settings = schema.normalized(input_dict)
    # can't have chain_std_deviation and chains_per_parameter defaults with restart_trace
    if run_settings.get('mcmc') is not None:
        if run_settings['mcmc'].get('restart_trace') is None:
            run_settings['mcmc']['chains_per_parameter'] = run_settings[
                'mcmc'].get('chains_per_parameter', 2)
            run_settings['mcmc']['chain_std_deviation'] = run_settings[
                'mcmc'].get('chain_std_deviation', 0.1)
    if not schema.validate(run_settings):
        raise ValueError(schema.errors)
    return run_settings
Ejemplo n.º 2
0
def get_run_settings(input_dict):
    """
    Validate settings from a dict of possible input.

    Performs the following actions:
    1. Normalize (apply defaults)
    2. Validate against the schema

    Parameters
    ----------
    input_dict : dict
        Dictionary of input settings

    Returns
    -------
    dict
        Validated run settings

    Raises
    ------
    ValueError
    """
    run_settings = schema.normalized(input_dict)
    # can't have chain_std_deviation and chains_per_parameter defaults with restart_trace
    if run_settings.get('mcmc') is not None:
        if run_settings['mcmc'].get('restart_trace') is None:
            run_settings['mcmc']['chains_per_parameter'] = run_settings[
                'mcmc'].get('chains_per_parameter', 2)
            run_settings['mcmc']['chain_std_deviation'] = run_settings[
                'mcmc'].get('chain_std_deviation', 0.1)
        if run_settings['mcmc']['scheduler'] == 'None':
            warnings.warn(
                "Setting scheduler to the string 'None' will be deprecated in ESPEI "
                "0.9. Use `null` in YAML or `None` in Python.", FutureWarning)
            run_settings['mcmc']['scheduler'] = None
    if not schema.validate(run_settings):
        raise ValueError(schema.errors)
    return run_settings