wtf_specs module

Define allowed values for wtf (what to fit).

Todo

Some tests disappeared with the new config method… Checking the correct match of compensating manual for example

WTF_COMMON = (   KeyValConfSpec(key='automatic_study',                    types=(<class 'str'>, <class 'NoneType'>),                    description='Automatically generate the list of failed '                                'cavities to avoid\n'                                '            manually typing all the cavities '                                'identifiers in systematic studies.\n'                                '            ',                    default_value=None,                    allowed_values=(   'single cavity failures',                                       'cryomodule failures'),                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='failed',                    types=(<class 'list'>,),                    description='Identifies list of failed cavities. This is '                                'typically a list of list of cavity identifiers '                                '(2D), but it can be a 1D list for automatic '                                'studies and it must be a 3D array if '                                "`strategy` is set to `'manual'`.",                    default_value=[[5]],                    allowed_values=None,                    is_mandatory=True,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='history_kwargs',                    types=(<class 'dict'>,),                    description='kwargs for the :class:`.OptimizationHistory`.',                    default_value={'folder': None},                    allowed_values=None,                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='id_nature',                    types=(<class 'str'>,),                    description='Indicates if `failed` is name of element(s), '                                'index of element(s),index of cavities. It can '                                'also be the index(es) of one or '                                'severalsection(s), or of one or several '                                'lattice(s).',                    default_value='element',                    allowed_values=(   'cavity',                                       'element',                                       'lattice',                                       'name',                                       'section'),                    is_mandatory=True,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='index_offset',                    types=(<class 'int'>,),                    description='\n'                                '            Specify whether user-provided '                                'cavity indices are 0-based or\n'                                '            1-based. Set `0` if the first '                                'cavity has index 0 (Python-style,\n'                                '            default). Set `1` if the first '                                'cavity has index 1\n'                                '            (human-friendly). This affects how '                                'the `failed` and\n'                                '            `compensating_manual` lists '                                'interpret integer indices.\n'                                '            ',                    default_value=0,                    allowed_values=(0, 1),                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='objective_preset',                    types=(<class 'str'>,),                    description='Objectives for the optimisation algorithm.',                    default_value='EnergyMismatch',                    allowed_values=(   'CorrectorAtExit',                                       'EnergyMismatch',                                       'EnergyPhaseMismatch',                                       'EnergySeveralMismatches',                                       'EnergySyncPhaseMismatch',                                       'RegularEnvelope',                                       'experimental',                                       'rephased_ADS',                                       'simple_ADS',                                       'sync_phase_as_objective_ADS'),                    is_mandatory=True,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='optimisation_algorithm',                    types=(<class 'str'>,),                    description='Name of optimisation algorithm.',                    default_value='DownhillSimplex',                    allowed_values=(   'bayesian_optimization',                                       'differential_evolution',                                       'downhill_simplex',                                       'downhill_simplex_penalty',                                       'experimental',                                       'explorator',                                       'least_squares',                                       'least_squares_penalty',                                       'nelder_mead',                                       'nelder_mead_penalty',                                       'NSGA-III',                                       'NSGA-III Multi-threaded',                                       'simulated_annealing'),                    is_mandatory=True,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='optimisation_algorithm_kwargs',                    types=(<class 'dict'>,),                    description='Keyword arguments passed to the optimisation '                                'algorithm.',                    default_value={},                    allowed_values=None,                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='strategy',                    types=(<class 'str'>,),                    description='How compensating cavities are selected.',                    default_value='k out of n',                    allowed_values=(   'corrector at exit',                                       'global',                                       'global_downstream',                                       'k out of n',                                       'l neighboring lattices',                                       'manual'),                    is_mandatory=True,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False))

Configuration keys that are common to all strategies.

_WTF_COMMON_NON_MANUAL = (   KeyValConfSpec(key='tie_politics',                    types=(<class 'str'>,),                    description='How to select the compensating elements when '                                'several are equidistant to the failure.',                    default_value='downstream first',                    allowed_values=('upstream first', 'downstream first'),                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False),     KeyValConfSpec(key='shift',                    types=(<class 'int'>,),                    description='Distance increase for downstream elements '                                '(`shift < 0`) or upstream elements (`shift > '                                '0`). Used to have a window of compensating '                                'cavities which is not centered around the '                                'failed elements.',                    default_value=0,                    allowed_values=None,                    is_mandatory=False,                    is_a_path_that_must_exists=False,                    action=None,                    warning_message=None,                    error_message=None,                    overrides_previously_defined=False,                    derived=False))

Configuration keys for all strategies but "manual"

apply_index_offset(self, toml_table, **kwargs)[source]

Apply the index_offset key.

Parameters:
Return type:

None

_apply_offset_to_nested_list(x, offset)[source]

Recursively subtract offset from integers in nested lists.

Parameters:
Return type:

int | list