hvl_ccb.utils.validation

validate_bool(x_name: str, x: object, logger: Optional[logging.Logger] = None) None[source]

Validate if given input x is a bool.

Parameters
  • x_name – string name of the validate input, use for the error message

  • x – an input object to validate as boolean

  • logger – logger of the calling submodule

Raises

TypeError – when the validated input does not have boolean type

validate_number(x_name: str, x: object, limits: Optional[Tuple] = (None, None), number_type: Union[Type[Union[int, float]], Tuple[Type[Union[int, float]], ...]] = (<class 'int'>, <class 'float'>), logger: Optional[logging.Logger] = None) None[source]

Validate if given input x is a number of given number_type type, with value between given limits[0] and limits[1] (inclusive), if not None. For array-like objects (npt.NDArray, List, Tuple, Dict) it is checked if all elements are within the limits and have the correct type.

Parameters
  • x_name – string name of the validate input, use for the error message

  • x – an input object to validate as number of given type within given range

  • logger – logger of the calling submodule

  • limits – [lower, upper] limit, with None denoting no limit: [-inf, +inf]

  • number_type – expected type or tuple of types of a number, by default (int, float)

Raises
  • TypeError – when the validated input does not have expected type

  • ValueError – when the validated input has correct number type but is not within given range