Validation¶
-
class
groundhog.general.validation.
Validator
(validationspec, outputonerrorspec)[source]¶ The Validator has the following features
- Automatic handling of validation errors
- Automatic handling of function output upon errors
- Possibility to override the default validation dictionary with custom validation
-
groundhog.general.validation.
check_layer_overlap
(df, raise_error=True, z_from_key=None, z_to_key=None)[source]¶ Checks possible overlap on a dataframe :param df: Dataframe with keys ‘z from [m]’ and ‘z to [m]’. Other keys can be used but then the arguments z_from_key and z_to_key need to be provided. :param raise_error: Boolean determining whether an error needs to be raised or whether a warning is sufficient (default behaviour is to raise an error warning) :param z_from_key: Key for start depth of the layer :param z_to_key: Key for end depth of the layer :return: Default behaviour: raises a warning if there are overlaps or gaps.
-
groundhog.general.validation.
map_args
(method, var, *args, **kwargs)[source]¶ Constructs a data structure with all parameters, their values and the validation parameters which need to be used during validation.
Parameters: - method – The function for which validation will be applied
- var – The validation data structure, entered as argument of the function decorator
- args – function arguments
- kwargs – function keyword arguments
- :returns dictionary var_validation which is a copy of the validation data structure
- it is possible to override __min and __max arguments
-
groundhog.general.validation.
validate_boolean
(var_name, value)[source]¶ Validates whether a variable can be used as a boolean
-
groundhog.general.validation.
validate_float
(var_name, value, min_value=None, max_value=None)[source]¶ Validates whether a variable can be used as a floating point number and whether it is within specified bounds If a value equals one of the bounds, the validation passes
-
groundhog.general.validation.
validate_integer
(var_name, value, min_value=None, max_value=None)[source]¶ Validates whether a variable can be used as an integer and whether it is within specified bounds If a value equals one of the bounds, the validation passes