def calculate_stats(records, tests):
    # scenario -> test -> concurrency -> [record]
    rec_map = collections.defaultdict(
        functools.partial(collections.defaultdict,
                          functools.partial(collections.defaultdict, list)))

    for record in records.values():
        if record not in 'test':
            continue

        aggregator = aggregators.get_aggregator(tests[record['test']])
        aggregator.record_summary(record)

        rec_map[record['scenario']][record['test']][
            record['concurrency']].append(record)

    for scenario, per_scenario in rec_map.items():
        for test, per_test in per_scenario.items():
            aggregator = aggregators.get_aggregator(tests[test])

            concurrency_aggregates = []
            for concurrency, per_concurrency in per_test.items():
                summary = aggregator.concurrency_summary(per_concurrency)
                if summary:
                    record_id = utils.make_record_id()
                    summary.update(dict(id=record_id,
                                        scenario=scenario, test=test,
                                        concurrency=concurrency,
                                        type='concurrency'))
                    records[record_id] = summary
                    concurrency_aggregates.append(summary)

            per_test_summary = aggregator.test_summary(concurrency_aggregates)
            if per_test_summary:
                record_id = utils.make_record_id()
                per_test_summary.update(dict(id=record_id,
                                             scenario=scenario, test=test,
                                             type='test'))
                records[record_id] = per_test_summary
dataset/ETHPy150Open openstack/shaker/shaker/engine/report.py/calculate_stats/swapped operands of `not in`