rizer.misc.check_utils#

Functions#

validate_positive(…)

Check if the value is a positive, finite, number.

check_keys_in_dict(→ None)

Check if the required keys are present in the dictionary.

Module Contents#

rizer.misc.check_utils.validate_positive(name: str, value: int, allow_zero: bool = False) int#
rizer.misc.check_utils.validate_positive(name: str, value: float, allow_zero: bool = False) float
rizer.misc.check_utils.validate_positive(name: str, value: numpy.integer, allow_zero: bool = False) numpy.integer
rizer.misc.check_utils.validate_positive(name: str, value: numpy.floating, allow_zero: bool = False) numpy.floating
rizer.misc.check_utils.validate_positive(name: str, value, allow_zero: bool = False) int | float

Check if the value is a positive, finite, number.

Parameters:
  • name (str) – Name of the variable for error messages.

  • value (int or float) – Value to check.

  • allow_zero (bool, optional) – Whether to allow zero as a valid value. Default is False.

Raises:
  • TypeError – Raised if the value is not a number.

  • ValueError – Raised if the value is not finite.

  • ValueError – Raised if the value is not positive.

rizer.misc.check_utils.check_keys_in_dict(d: dict, required_keys: list[str] | str, dict_name: str = '') None#

Check if the required keys are present in the dictionary.

Parameters:
  • d (dict) – The dictionary to check.

  • required_keys (list of str or str) – The list of required keys or a single key as a string.

  • dict_name (str, optional) – A custom error message to include in the KeyError.

Raises:

KeyError – Raised if any of the required keys are missing from the dictionary.