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.KEYS_EXPECTED_AS_LIST = ['basis_functions']
- pylbo.automation.generator._ensure_nb_names_and_nb_runs_matches(names: str | list[str], nb_runs: int) list[str]
Ensures that the number of names matches the number of runs.
- pylbo.automation.generator._validate_basenames(basenames: list[str]) list[str]
Validates the basenames for given parfiles.
- pylbo.automation.generator._validate_output_dir(output_dir, subdir)
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:
- pylbo.automation.generator._handle_expected_item_list(item)
- class pylbo.automation.generator.ParfileGenerator(parfile_dict, basename=None, output_dir=None, subdir=True, prefix_numbers=True, nb_prefix_digits=4)
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.
- parfile_dict
- nb_runs
- basenames = ['parfile']
- output_dir
- _use_prefix = True
- _nb_prefix_digits = 4
- parfiles = []
- container
- _get_and_check_item(namelist, name, allowed_dtypes)
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
- create_namelist_from_dict()
Creates one major namelist from the given dictionary.
- Raises:
If the original dictionary is not empty after everything should be popped
If there is an inconsistency between array sizes of dictionary items