Input data validations¶
Module containing base QC which call multiple QC functions and could be applied on a DataBundle.
- marine_qc.validations.is_func_param(func, param)[source]
Return True if param is the name of a parameter of function func.
- marine_qc.validations.is_in_data(name, data)[source]
Return True if named column or variable, name, is in data.
- marine_qc.validations.validate_arg(key, value, func_name, parameters, type_hints, reserved_keys, has_arguments)[source]
Validate argument against a function’s signature, taking decorators into account.
- Parameters:
key (
str) – The name of the argument to validate.value (
Any) – The value of the argument to validate.func_name (
str) – The name of the function (used in error message).parameters (
Mapping[str,inspect.Parameter]) – A mapping of parameter names to inspect.Parameter objects, typically from inspect.signature(func).parameters.type_hints (
Mapping[str,type]) – A mapping of parameter names to expected types, typically from typing.get_type_hints(func).reserved_keys (
set[str]) – Argument names that are considered reserved and should nor raise errors.has_arguments (
bool) – Whether the function accepts arbitrary arguments.
- Return type:
- marine_qc.validations.validate_args(func, args=None, kwargs=None)[source]
Validate positional and keyword arguments against a function’s signature, taking decorators into account.
This function checks that: - All provided keyword arguments correspond to valid parameters of the given function. - All required parameters of the function (i.e., parameters without default values) are present in the provided keyword arguments.
- Parameters:
func (
Callable[...,Any]) – The function whose signature is used for validation.args (
Sequence[Any], optional) – Sequence of arguments intended to be passed to func.kwargs (
Mapping[str,Any], optional) – Dictionary of keyword arguments intended to be passed to func.
- Raises:
ValueError – If kwargs contains a key that is not a parameter of func.
TypeError – If a required parameter of func is missing from kwargs.
- Return type:
- marine_qc.validations.validate_dict(input_dict)[source]
Validate that the input is a dictionary with string keys and dictionary values.
This function checks that: - input_dict is a dictionary. - All keys in the dictionary are strings. - All top-level values in the dictionary are themselves dictionaries.
- marine_qc.validations.validate_type(value, expected)[source]
Recursively validate that a value matches the expected type hint.