Tracer

class openfisca_core.tracers.ComputationLog(full_tracer)[source]
print_log(aggregate=False, max_depth=9223372036854775807)[source]

Print the computation log of a simulation.

If aggregate is False (default), print the value of each computed vector.

If aggregate is True, only print the minimum, maximum, and average value of each computed vector.

This mode is more suited for simulations on a large population.

If max_depth is sys.maxsize (default), print the entire computation.

If max_depth is set, for example to 3, only print computed vectors up to a depth of max_depth.

Return type:

None

class openfisca_core.tracers.FlatTrace(full_tracer)[source]
static key(node)[source]

Return the key of a node.

Return type:

NewType(NodeKey, str)

class openfisca_core.tracers.PerformanceLog(full_tracer)[source]
class openfisca_core.tracers.TraceNode(name, period, parent=None, children=<factory>, parameters=<factory>, value=None, start=0.0, end=0.0)[source]

A node in the tracing tree.

append_child(node)[source]

Append a child to the node.

Return type:

None

calculation_time(round_=True)[source]

Calculate the time spent in the node.

Parameters:

round – Whether to round the result.

Returns:

float – The time spent in the node.

Return type:

float

Examples

>>> from openfisca_core import tracers
>>> node = tracers.TraceNode("variable", 2020)
>>> node.start = 1.123122313
>>> node.end = 1.12312313123
>>> node.calculation_time()
8.182e-07
>>> node.calculation_time(round_=False)
8.182299999770493e-07
children: list[TraceNode]

The children of the node.

end: float = 0.0

The end time of the node.

formula_time()[source]

Calculate the time spent on the formula.

Returns:

float – The time spent on the formula.

Return type:

float

Examples

>>> from openfisca_core import tracers
>>> node = tracers.TraceNode("variable", 2020)
>>> node.start = 1.123122313 * 11
>>> node.end = 1.12312313123 * 11
>>> child = tracers.TraceNode("variable", 2020)
>>> child.start = 1.123122313
>>> child.end = 1.12312313123
>>> for i in range(10):
...     node.children = [child, *node.children]
>>> node.formula_time()
8.182e-07
name: str

The name of the node.

parameters: list[TraceNode]

The parameters of the node.

parent: None | TraceNode = None

The parent of the node.

period: Union[NewType(PeriodInt, int), Period]

The period of the node.

static round(time)[source]

Keep only 4 significant figures.

Parameters:

time (float) – The time to round.

Returns:

float – The rounded time.

Return type:

float

Examples

>>> from openfisca_core import tracers
>>> tracers.TraceNode.round(0.000123456789)
0.0001235
start: float = 0.0

The start time of the node.

value: None | ndarray[Any, dtype[generic]] = None

The value of the node.

class openfisca_core.tracers.TracingParameterNodeAtInstant(parameter_node_at_instant, tracer)[source]