The Reporter class
Collection of values related to reporting.
This class exists to collect some values related to reporting in its derived [1] classes. These values are:
This class has limited (no?) utility on its own, and you are unlikely to want to use it directly.
Important
The classes that we claim derive from Reporter
in this documentation
have all the methods of the Reporter
class but, for boring technical
reasons, are not formally subclasses of Reporter
. If thing
is an
instance of a class derived from Reporter
, then you can use thing
as if it were an instance of Reporter
but
isinstance(thing, Reporter)
will return False
.
Footnotes
Contents
Collection of values related to reporting. |
|
Copy a |
|
Initialize an existing Reporter object. |
|
Get the time point of the last report. |
|
Check if it is time to report. |
|
Overloaded function. |
|
Overloaded function. |
|
Set the last report time point to now. |
|
Reset the start time (and last report) to now. |
|
Get the start time. |
Full API
- class Reporter
- __init__(self: Reporter) None
Default construct a
Reporter
object such that the following hold:report_prefix()
is empty;report_every()
is set to 1 second;last_report()
is now;start_time()
is now.
- init(self: Reporter) Reporter
Initialize an existing Reporter object.
This function puts a
Reporter
object back into the same state as if it had been newly default constructed.- Returns:
self.
- Return type:
See also
- last_report(self: Reporter) datetime.datetime
Get the time point of the last report. This function returns the time point of the last report, as set by one of:
- Returns:
- Return type:
- report(self: Reporter) bool
Check if it is time to report.
This function can be used to check if enough time has passed that we should report again. That is if the time between
last_report()
and now is greater than the value ofreport_every()
. IfTrue
is returned, thenlast_report()
is set to now.- Returns:
A value of type
bool
.- Return type:
See also
- report_every(*args, **kwargs)
Overloaded function.
- report_every(self: Reporter, val: datetime.timedelta) Reporter
Set the minimum elapsed time between reports.
This function can be used to specify at run time the minimum elapsed time between two calls to
report()
that will returnTrue
. Ifreport()
returnsTrue
at times
, thenreport()
will only returnTrue
again after at least times + val
has elapsed.- Parameters:
val (datetime.timedelta) – the amount of time between reports.
- Returns:
self.
- Return type:
See also
- report_every(self: Reporter) datetime.timedelta
Get the minimum elapsed time between reports.
- Returns:
The time delta between reports.
- Return type:
- report_prefix(*args, **kwargs)
Overloaded function.
- report_prefix(self: Reporter, val: str) Reporter
Set the prefix string for reporting.
This function sets the return value of
report_prefix()
to (a copy of) the argument val. Typically this prefix should be the name of the algorithm being run at the outmost level.
- report_prefix(self: Reporter) str
Get the current prefix string for reporting.
This function gets the current value of the prefix string for reporting (set via
report_prefix
), which is typically the name of the algorithm being run at the outmost level.- Returns:
The prefix string.
- Return type:
- reset_last_report(self: Reporter) Reporter
Set the last report time point to now.
- Returns:
self.
- Return type:
- reset_start_time(self: Reporter) Reporter
Reset the start time (and last report) to now.
- Returns:
self.
- Return type:
- start_time(self: Reporter) datetime.datetime
Get the start time.
This is the time point at which
reset_start_time()
was last called, which is also the time of construction of aReporter
instance ifreset_start_time()
is not explicitly called.- Returns:
The time delta representing the start time.
- Return type: