Reference 〉Decorator

@Helipad.reporter( str key = None, int smooth = None )

A decorator to register a column in the data to be collected each period. The decorated function should take one argument, the model, and output a recordable value.

This decorator can be used bare (i.e. without parentheses), in which case the column name takes the name of the decorated function. Further arguments are passed to Data.addReporter().

Parameters

  • key str, optional

    The name of the data column, if overriding the function name.

    Default value: None

  • smooth int, optional

    Replaces the series with a decaying average for the purposes of graphing. Higher values smooth the data more strongly. The original data is recorded in a new column with the same name but postfixed with -unsmooth.

    Default value: None

Notes and Examples

  1. charwick

    Aug 06, 2020 at 4:16

    This example registers a reporter to be placed in the column 'hsum'.

    @heli.reporter
    def hsum(model):
    	upop = model.agent('urban')
    	return sum([a.H for a in model.agent('urban')]) if len(upop) > 0 else 1

    The column name can be changed without changing the name of the function by decorating with, e.g., @heli.reporter('sumofh') instead.

  2. Contribute a Note

    Your email address will not be published. Required fields are marked *

    You may use limited HTML for formatting. Please embed blocks of code in <pre><code> </code></pre> tags.

History