pylbo.automation.generator
Attributes
Classes
Handles parfile generation. |
Functions
|
Ensures that the number of names matches the number of runs. |
|
Validates the basenames for given parfiles. |
|
Validates and returns the output directory for the parfiles. |
Module Contents
- pylbo.automation.generator._ensure_nb_names_and_nb_runs_matches(names: str | list[str], nb_runs: int) list[str] [source]
Ensures that the number of names matches the number of runs.
- pylbo.automation.generator._validate_basenames(basenames: list[str]) list[str] [source]
Validates the basenames for given parfiles.
- pylbo.automation.generator._validate_output_dir(output_dir, subdir)[source]
Validates and returns the output directory for the parfiles.
- Parameters:
- Raises:
NotADirectoryError – If the output directory is not found.
- Returns:
output – The resolved path to the output directory with “parfiles” appended.
- Return type:
- class pylbo.automation.generator.ParfileGenerator(parfile_dict, basename=None, output_dir=None, subdir=True, prefix_numbers=True, nb_prefix_digits=4)[source]
Handles parfile generation.
- Parameters:
parfile_dict (dict) – Dictionary containing the keys to be placed in the parfile.
basename (str, list[str]) – The basename for the parfile, the .par suffix is added automatically and is not needed. If not provided, the basename will default to parfile. Can be a list of names as well if multiple parfiles are being generated.
output_dir (str, PathLike) – Output directory where the parfiles are saved, defaults to the current working directory if not specified.
subdir (boolean) –
- If True (default), creates a subdirectory under output_dir called
parfiles in which the parfiles will be saved.
prefix_numbers (boolean) – If True prepends the basename by a n-digit number (e.g. xxxxmyparfile.par). The number of digits is specified by nb_prefix_digits.
nb_prefix_digits (int) – Number of digits to prepend to the basename if prefix_numbers is True. Defaults to 4.
- _get_and_check_item(namelist, name, allowed_dtypes)[source]
Does typechecking on the various dictionary keys supplied to the parfile generator. Pops the key from the dictionary.
- Parameters:
- Raises:
TypeError – If the types do not match, e.g. if “gridpoints” is specified as a float value when it should be an integer.
- Returns:
item – The item popped from the dictionary corresponding to the given key.
- Return type:
any