emodpy.utils package#

emodpy.utils.is_valid_key_value_pair(s: str) bool[source]#
emodpy.utils.validate_key_value_pair(s: str) str[source]#
emodpy.utils.validate_value_range(param: float | int, param_name: str, min_value: float | None = None, max_value: float | None = None, param_type: type = <class 'float'>)[source]#

Validate that the parameter is within the specified range and of the specified type(float or int only). Return the parameter value if it passes the validation.

emodpy.utils.validate_bins(bins: list[float], param_name: str, min_value: float | None = None, max_value: float | None = None)[source]#

Validate that the array’s values are within the specified range and of the specified type(float or int only) and in ascending order.

Return the parameter value if it passes the validation.

emodpy.utils.validate_node_ids(node_ids: list[int] | None) list[int][source]#

todo: validate node_ids against nodes in the demographics file

emodpy.utils.validate_node_property(node_property: str) str[source]#

Checks if a node property is valid.

emodpy.utils.validate_individual_property(individual_property: str) str[source]#

Checks if an individual property is valid.

emodpy.utils.validate_intervention_name(intervention_name: str) str[source]#

Checks if an individual intervention name is valid.

emodpy.utils.validate_individual_event(event: str) str[source]#

Checks if an individual event is valid.

emodpy.utils.validate_node_event(event: str) str[source]#

Checks if an node event is valid.

emodpy.utils.validate_coordinator_event(event: str) str[source]#

Checks if an coordinator event is valid.

emodpy.utils.validate_surveillance_event(event: str)[source]#

Checks if an coordinator event is valid.

emodpy.utils.validate_list_of_strings(strings: list[str], param_name: str, process_string_callback: Callable | None = None, empty_list_ok: bool = False) list[str][source]#

Helper function to validate a list of strings, ensuring they meet specified conditions.

Future Work: - Ensure the events we are listening for actually exist in the campaign.

Parameters:
  • strings (list[str]) – The list of strings to validate.

  • param_name (str) – The name of the parameter being validated.

  • process_string_callback (Callable[[str, bool], None]) – Function to process each string.

  • empty_list_ok (bool) – Whether an empty list is allowed.

Returns:

The validated list of strings.

Return type:

list[str]

Raises:
  • ValueError – If the list is empty and empty_list_ok is False.

  • ValueError – If strings is not a list.

  • ValueError – If any string in strings does not meet validation criteria.

Submodules#