biogeme.tools.checks module

Utilities to perform various checks

Michel Bierlaire Fri Apr 5 11:09:39 2024

biogeme.tools.checks.check_consistency_of_named_dicts(named_dicts)[source]

Verify that all dictionaries have the same set of keys. If not, report the inconsistencies.

Parameters:

named_dicts (dict[str, dict[Any, Any]]) – A dictionary where each key is a name (str) and each value is a dictionary to check.

Return type:

tuple[bool, str | None]

Returns:

True if keys are consistent across all dictionaries, False otherwise. If not consistent, returns a report detailing the inconsistencies.

biogeme.tools.checks.validate_dict_types(parameter, name, value_type, key_type=<class 'int'>)[source]

Validate the types of keys and values in a dictionary.

Parameters:
  • parameter (dict) – The dictionary parameter to validate.

  • name (str) – The name of the parameter for error messages.

  • value_type (type) – The expected type of the dictionary values.

  • key_type (type) – The expected type of the dictionary keys. Default is int.

Raises:

TypeError – If key or value types do not match expectations.

Return type:

None