Input Validators#

validate_int(value, value_descr: str = 'value', lower_bound: int = None, upper_bound: int = None)[source]#

Validates that the input value is an int. Lower and upper bounds on the value of the int can be provided.

Parameters:
  • value – The value to validate

  • value_descr (str, default: "value") – A description of the value used in the message of the exceptions raised when the value is not a valid input.

  • lower_bound (int, default: None) – A lower bound on the value, the value cannot be strictly smaller than the bound.

  • upper_bound (int, default: None) – An upper bound on the value, the value cannot be strictly larger than the bound.

Raises:
  • TypeError – When the value is not an int or cannot be cast as an int.

  • ValueError – When the value is either strictly smaller than the lower bound or strictly greater than the upper bound.

validate_num_voters_candidates(func)[source]#

Decorator that tests that the first two arguments of the function are integers larger than 0.

Parameters:

func (Callable) – The decorated function