ape.parts.countdown.countdown.CountdownTimer

class ape.parts.countdown.countdown.CountdownTimer(repetitions=1, end_time=None, total_time=None, *args, **kwargs)

A time-tracker that counts down

Param:
  • repetitions: number of calls to accept before stopping
  • end_time: datetime to stop
  • total_time: timedelta for amount of time to run
__init__(repetitions=1, end_time=None, total_time=None, *args, **kwargs)
Param:
  • repetitions: number of calls to accept before stopping
  • end_time: datetime to stop
  • total_time: timedelta for amount of time to run

Methods

__init__([repetitions, end_time, total_time])
param:
append(item) Appends the item to the times array
close() Resets the attributes (makes __call__ always evaluate to false, not once like default)
log_error(error[, message]) Logs the error in bold red
log_estimated_time_remaining() Log an estitmated remaining time based on the median and repetitions x xx
log_update(elapsed) Outputs to the log the most recent elapsed time information
percentile(percentile) calculates the percentile (e.g. 50 gets the median (the 50% item))
time_remains() Evaluates if there is still time (or repetitions) remaining

Attributes

log The logger method indicated by the log_level
logger
return:A logging object.
times collection of elapsed times
append(item)

Appends the item to the times array

Param:
  • item: item to append to self.times (a numpy array)
Postcondition:

self.times contains item

close()

Resets the attributes (makes __call__ always evaluate to false, not once like default)

Postcondition:
  • self.end_time is None
  • self.total_time is None
  • self.repetitions is 0
  • self.start is None
  • self._times is None
log_error(error, message='')

Logs the error in bold red

Param:
  • error: error type (prefix in red and bold)
  • message: descriptive message (red but not bold)
log_estimated_time_remaining()

Log an estitmated remaining time based on the median and repetitions x xx

log_update(elapsed)

Outputs to the log the most recent elapsed time information

Param:
  • elapsed: timedelta
percentile(percentile)

calculates the percentile (e.g. 50 gets the median (the 50% item))

Returns:value for percintile of self.times as a timedelta
time_remains()

Evaluates if there is still time (or repetitions) remaining

Precondition:if total_time is set, self.start is set
Returns:True if reps or time remains, False otherwise
log

The logger method indicated by the log_level

Returns:logger.debug or logger.info
logger
Returns:A logging object.
times

collection of elapsed times

Navigation