pat2vec.util.calculate_interval

Functions

calculate_interval(start_date, total_delta, ...)

Calculates how many 'interval_delta' chunks fit inside 'total_delta'.

pat2vec.util.calculate_interval.calculate_interval(start_date, total_delta, interval_delta)[source]

Calculates how many ‘interval_delta’ chunks fit inside ‘total_delta’.

This function iteratively adds the interval_delta to the start_date until it exceeds the total duration specified by total_delta. It counts how many full intervals fit within this period.

Parameters:
  • start_date (datetime) – The starting date of the total period.

  • total_delta (relativedelta) – The total duration from the start date.

  • interval_delta (relativedelta) – The duration of a single interval chunk.

Return type:

int

Returns:

The number of complete intervals that fit within the total duration.

Raises:

ValueError – If interval_delta is not a positive duration.