clevar.clv_yaml.helper_funcs module

@file yaml/helper_funcs.py Helper functions for command line execution

clevar.clv_yaml.helper_funcs.add_dicts_diff(dict1, dict2, pref='', diff_lines=None)[source]

Adds the differences between dictionaries to a list

Parameters
  • dict1 (dict) – Dictionaies to be compared

  • dict2 (dict) – Dictionaies to be compared

  • pref (str) – Prefix to be added in output

  • diff_lines (list, None) – List where differences will be appended to. If None, it is a new list.

clevar.clv_yaml.helper_funcs.add_mem_catalog(cat, cat_config)[source]

Make a clevar.MemCatalog object based on config

Parameters

cat_config (dict) – MemCatalog configuration

Returns

MemCatalog based on input config

Return type

clevar.MemCatalog

clevar.clv_yaml.helper_funcs.deep_update(dict_base, dict_update)[source]

Update a multi-layer dictionary.

Parameters
  • dict_base (dict) – Dictionary to be updated

  • dict_update (dict) – Dictionary with the updates

Returns

dict_base – Updated dictionary (the input dict is also updated)

Return type

dict

clevar.clv_yaml.helper_funcs.get_dicts_diff(dict1, dict2, keys=None, header=['Name', 'dict1', 'dict2'], msg='')[source]

Get all the differences between dictionaries, accounting for nested dictionaries. If there are differences, a table with the information is printed.

Parameters
  • dict1 (dict) – Dictionaries to be compared

  • dict2 (dict) – Dictionaries to be compared

  • keys (list, None) – List of keys to be compared. If None, all keys are compared

  • header (str) – Header for differences table

  • msg (str) – Message printed before the differences

Returns

List of dictionaries differences

Return type

diff_lines

clevar.clv_yaml.helper_funcs.get_input_loop(options_msg, actions)[source]

Get input from fixed values

Parameters
  • options_msg (str) – Description of the possible input options

  • actions (dict) – Dictionary with the actions to be made. Values must be (function, args, kwargs)

clevar.clv_yaml.helper_funcs.loadconf(config_file, load_configs=None, add_new_configs=None, fail_action='ask', check_matching=False)[source]

Load configuration from yaml file, creates output directory and config.log.yml

Parameters
  • config_file (str) – Yaml configuration file.

  • load_configs (list, None) – List of configurations loaded (will be checked with config.log.yml).

  • add_new_configs (list, None) – List of configurations that will be automatically added if not in config.log.yml.

  • fail_action (str) – Action to do when there is inconsistency in configs. Options are ‘ask’, ‘overwrite’ and ‘quit’

  • check_matching (bool) – Check matching config

Returns

Configuration for clevar

Return type

dict

clevar.clv_yaml.helper_funcs.make_bins(input_val, log=False)[source]

Make array for bins string input

Parameters
  • input_val (any) – Value given by yaml config

  • log (bool) – Use log scale

Returns

Bins to be used

Return type

int, array

clevar.clv_yaml.helper_funcs.make_catalog(cat_config)[source]

Make a clevar.ClCatalog object based on config

Parameters

cat_config (dict) – ClCatalog configuration

Returns

ClCatalog based on input config

Return type

clevar.ClCatalog

clevar.clv_yaml.helper_funcs.make_cosmology(cosmo_config)[source]

Make a cosmology object based on config

Parameters

cosmo_config (dict) – Cosmology configuration

Returns

Cosmology based on the input config

Return type

clevar.Cosmology

clevar.clv_yaml.helper_funcs.read_yaml(filename)[source]

Read yaml file

Parameters

filename (str) – Name of yaml file

Returns

config – Dictionary with yaml file info

Return type

dict

clevar.clv_yaml.helper_funcs.write_yaml(config, filename)[source]

Write yaml file

Parameters
  • config (dict) – Dictionary to write

  • filename (str) – Name of yaml file