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

Reporter

Collection of values related to reporting.

Reporter.copy(…)

Copy a Reporter object.

Reporter.init(…)

Initialize an existing Reporter object.

Reporter.last_report(…)

Get the time point of the last report.

Reporter.report(…)

Check if it is time to report.

Reporter.report_every(…)

Overloaded function.

Reporter.report_prefix(…)

Overloaded function.

Reporter.reset_last_report(…)

Set the last report time point to now.

Reporter.reset_start_time(…)

Reset the start time (and last report) to now.

Reporter.start_time(…)

Get the start time.

Full API

class Reporter
__init__(self: Reporter) None

Default construct a Reporter object such that the following hold:

copy(self: Reporter) Reporter

Copy a Reporter object.

Returns:

A copy.

Return type:

Reporter

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:

Reporter

See also

Reporter()

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:

A datetime.datetime.

Return type:

datetime.datetime

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 of report_every(). If True is returned, then last_report() is set to now.

Returns:

A value of type bool.

Return type:

bool

See also

report_every.

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 return True. If report() returns True at time s, then report() will only return True again after at least time s + val has elapsed.

Parameters:

val (datetime.timedelta) – the amount of time between reports.

Returns:

self.

Return type:

Reporter

See also

report_every

report_every(self: Reporter) datetime.timedelta

Get the minimum elapsed time between reports.

Returns:

The time delta between reports.

Return type:

datetime.timedelta

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.

Parameters:

val (str) – the new value of the report prefix.

Returns:

self.

Return type:

Reporter

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:

str

reset_last_report(self: Reporter) Reporter

Set the last report time point to now.

Returns:

self.

Return type:

Reporter

reset_start_time(self: Reporter) Reporter

Reset the start time (and last report) to now.

Returns:

self.

Return type:

Reporter

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 a Reporter instance if reset_start_time() is not explicitly called.

Returns:

The time delta representing the start time.

Return type:

datetime.datetime