Skip to content

isimip_utils.parameters

Utility functions for the work with parameters and placeholders.

get_permutations(parameters)

Generate all permutations from parameter value lists.

Parameters:

Name Type Description Default
parameters dict[str, list]

Dictionary mapping parameter names to lists of values.

required

Returns:

Type Description
tuple[tuple]

Tuple of tuples representing all possible combinations of parameter values.

get_placeholders(parameters, permutation)

Convert a permutation tuple into a dictionary of placeholders.

Parameters:

Name Type Description Default
parameters dict[str, list]

Dictionary mapping parameter names to lists of values.

required
permutation tuple

Tuple of values representing one permutation.

required

Returns:

Type Description
dict

Dictionary mapping parameter names to their values in this permutation.

join_parameters(parameters, max_count=5, max_label='various')

Join parameter values into strings, with fallback for large value sets.

Parameters:

Name Type Description Default
parameters dict[str, list[str]]

Dictionary mapping parameter names to lists of values.

required
max_count int

Maximum number of values to join (default: 5).

5
max_label str

Label to use when value count exceeds max_count (default: 'various').

'various'

Returns:

Type Description
dict[str, str]

Dictionary mapping parameter names to joined strings or max_label.

copy_placeholders(*placeholder_args, **kwargs)

Merge multiple placeholder dictionaries and additional kwargs.

Parameters:

Name Type Description Default
*placeholder_args dict

Variable number of placeholder dictionaries to merge.

()
**kwargs Any

Additional key-value pairs to add to the result.

{}

Returns:

Type Description
dict

Dictionary containing all merged placeholders.

apply_placeholders(path_template, placeholders)

Apply placeholders to a string or path, ensuring that the name of the path is lower case

Parameters:

Name Type Description Default
path_template str | Path

Path template as string or path.

required
placeholders dict

Placeholder dictionary.

required

Returns:

Type Description
Path

Path with the applied placeholders.