Example #1
0
    def test_evalformat(self):
        ex = Experiment()
        ex.addOutputFile(test_out)
        ex.collectData()

        for (index, indexsplit) in ((index, indexsplit) for index in eval_index
                                    for indexsplit in eval_indexsplit):
            for (cols, fgs) in ((cols, fgs) for cols in self.test_cols
                                for fgs in self.test_fgs):
                ev = IPETEvaluation(index=index, indexsplit=indexsplit)
                if cols is not None:
                    for (ind_c, ind_a) in cols:
                        col = IPETEvaluationColumn(**columns[ind_c])
                        if col_filters[ind_c] is not None:
                            colfilter = IPETFilter(**col_filters[ind_c])
                            col.addFilter(colfilter)
                        if ind_a:
                            agg = Aggregation(**aggs[ind_c])
                            col.addAggregation(agg)
                        ev.addColumn(col)
                if fgs is not None:
                    for ind in fgs:
                        fg = IPETFilterGroup(**filtergroups[ind])
                        if filters[ind] is not None:
                            fgfilter = IPETFilter(**filters[ind])
                            fg.addFilter(fgfilter)
                        ev.addFilterGroup(fg)

                try:
                    tab_long, tab_agg = ev.evaluate(ex)
                except AttributeError as e:
                    self.assertTrue((
                        cols is None or fgs is None
                    ), "Either the number of columns or the number of filtergroups should be 0."
                                    )
                    continue

                self.assertEqual(type(tab_long), pd.DataFrame,
                                 "Type of long table wrong.")
                self.assertEqual(type(tab_agg), pd.DataFrame,
                                 "Type of aggregated table wrong.")

                # do not allow rowindex to be empty
                if indexsplit == 0:
                    indexsplit = 1

                rowindex_level = len(index.split()[:indexsplit])
                columns_level = len(index.split()[indexsplit:])

                self.assertEqual(tab_long.columns.nlevels, columns_level + 1,
                                 "Level of columnindex of long table wrong.")
                self.assertEqual(tab_agg.index.nlevels, columns_level + 1,
                                 "Level of rowindex of agg table wrong.")

                self.assertEqual(tab_long.index.nlevels, rowindex_level,
                                 "Level of rowindex of long table wrong.")
Example #2
0
    def createAndEvaluateColumn(self, col):
        ev = IPETEvaluation(index="A B C", indexsplit=3)
        ev.addColumn(col)
        ev.evaluate(self.helper)

        return ev