def report(self, test_name):
        test = self.tests.find_one({'_id': test_name})
        if test is None:
            raise Exception(test_name % 'unknown test "%s"')

        report = {
            'test_name': test_name,
            'results': []
        }

        trials = sparsearray(int)

        for result in self.results.find({'t': test_name}):
            if result['s'] != test['s'][:len(result['s'])]:
                # invalid order of steps recorded
                continue

            for i in xrange(len(result['s'])):
                trials[result['n']][i] += 1

        for i, alternative in enumerate(test['a']):
            funnel = []
            alt = {'alternative': alternative, 'funnel': funnel}
            report['results'].append(alt)
            for s, stepspair in enumerate(pairwise(test['s'])):
                att = trials[i][s]
                con = trials[i][s + 1]
                funnel.append({
                    'stage': stepspair,
                    'attempted': att,
                    'converted': con,
                })

        return report
dataset/ETHPy150Open dcrosta/dabble/dabble/backends/mongodb.py/MongoResultStorage.report/swapped operands of `%`