pymodalib.utils.parameters module

exception BadParametersException

Bases: Exception

float_or_none(value: Any) → Optional[float]
int_or_none(value: Any) → Optional[int]
sanitise(dictionary: Dict[KT, VT]) → Dict[KT, VT]

Creates a sanitised copy of a dictionary, removing all None items. Does not modify the existing dictionary.

Parameters:dictionary – the dictionary to remove None items from
Returns:the new dictionary
verify_parameter(param: Any, possible_values: Iterable[Any]) → None

Checks whether a parameter is in a list of possible values. This is useful when parsing parameters which have particular string values.

Parameters:
  • param – the parameter
  • possible_values – the possible values that the parameter could take
Returns:

whether the parameter is a valid value