docs: def _clean_frequency(frequency):
      """Converts a frequency value to an integer. Raises an error if an invalid
      type is given.
  
      :param frequency: A frequency
      :type frequency: int or datetime.timedelta
      :rtype: int
      """
      if isinstance(frequency, int):
          return frequency
      elif isinstance(frequency, datetime.timedelta):
          return int(frequency.total_seconds())
  
      raise ValueError('Invalid frequency {!r}'.format(frequency))