def test_metricscontainer_autoname():
    """Tests automatic names (and dependencies) from inspection."""

    def constant_a(_):
        """Constant a help."""
        return 1.

    def constant_b(_):
        return 2.

    def add(_, constant_a, constant_b):
        return constant_a + constant_b

    def sub(_, constant_a, constant_b):
        return constant_a - constant_b

    def mul(_, add, sub):
        return add * sub

    m = mm.metrics.MetricsHost()
    m.register(constant_a, deps='auto')
    m.register(constant_b, deps='auto')
    m.register(add, deps='auto')
    m.register(sub, deps='auto')
    m.register(mul, deps='auto')

    assert m.metrics['constant_a']['help'] == 'Constant a help.'

    summary = m.compute(mm.MOTAccumulator.new_event_dataframe(), metrics=['mul', 'add'])
    assert summary.columns.values.tolist() == ['mul', 'add']
    assert summary.iloc[0]['mul'] == -3.
    assert summary.iloc[0]['add'] == 3.
Tests automatic names (and dependencies) from inspection.
motmetrics/tests/test_metrics.py