Validator of algorithm input data¶
This module validates the input data received by an algorithm
- encore.validators.algorithm_inputs.get_algorithm_config(algorithm: str) dict¶
Returns the config dictionary for the specified algorithm.
- Parameters:
algorithm (str) – Key of the algorithm
- Raises:
RuntimeError – If the config file is not found.
- Returns:
Dictionary with the config of the algorithm
- Return type:
dict
- encore.validators.algorithm_inputs.simple_validate(algorithm: str, input_data: dict[str, ndarray]) dict¶
Validates the input data given as a dict for a given algorithm, using as reference the data in the ENCORE config file and the basic definition of each ENCORE variable. This validation includes: - Checking that all the needed variables by the algorithm are present in the input dict - Checking that all are numpy arrays - Checking the number of dimensions of each variable - Checking that some variables are binary arrays
- Parameters:
algorithm (str) – String with the key (short name) of the algorithm
input_data (dict[str, np.ndarray]) – Dictionary mapping the name of a ENCORE variable with is value
- Raises:
RuntimeError – If the input data dict does not contains a needed variable
RuntimeError – If a input variable is not a numpy array
RuntimeError – If the numpy matrix has a invalid number of dimensions
RuntimeError – If a variable needs to be binary and it is not.
- Returns:
Same input dictionary validated
- Return type:
dict[str, np.ndarray]