def testAggregateCount(self):

        period = self.period
        assertEqual = self.assertEqual

        # Aggregate
        totals = period.aggregate(S3TimeSeriesFact("count", "base"))

        # Check rows
        expected_rows = {"A": [4],
                         "B": [4],
                         "C": [4],
                         }
        rows = period.rows
        assertEqual(set(rows.keys()), set(expected_rows.keys()))
        for k, v in rows.items():
            assertEqual(v, expected_rows.get(k),
                        msg = "Row %s: %s != %s" %
                              (k, v, expected_rows.get(k)))

        # Check columns
        expected_cols = {1: [4],
                         2: [5],
                         3: [3],
                         }
        cols = period.cols
        assertEqual(set(cols.keys()), set(expected_cols.keys()))
        for k, v in cols.items():
            assertEqual(v, expected_cols.get(k),
                        msg = "Column %s: %s != %s" %
                              (k, v, expected_cols.get(k)))

        # Check matrix
        expected_matrix = {("A", 1): [2],
                           ("A", 2): [2],
                           ("B", 2): [2],
                           ("B", 3): [2],
                           ("C", 1): [2],
                           ("C", 2): [1],
                           ("C", 3): [1],
                           }
        matrix = period.matrix
        assertEqual(set(matrix.keys()), set(expected_matrix.keys()))
        for k, v in matrix.items():
            assertEqual(v, expected_matrix.get(k),
                        msg = "Cell %s: %s != %s" %
                              (k, v, expected_matrix.get(k)))

        # Check total
        expected_totals = [12]
        assertEqual(period.totals, expected_totals)
        assertEqual(totals, expected_totals)

    # -------------------------------------------------------------------------
Test aggregation: count
dataset/ETHPy150Open sahana/eden/modules/unit_tests/s3/s3timeplot.py/PeriodTests.testAggregateCount