Пример #1
0
 def group(self, groups, config):
     new_results = []
     for k in groups.keys():
         title = "%s (n=%d)" % (k, len(groups[k])) if self.print_n else k
         res = ResultSet(TITLE=title, NAME=self.orig_name)
         res.create_series([s['data'] for s in self.orig_series])
         cutoff = config.get('cutoff', None)
         x = 0
         for r in groups[k]:
             if cutoff:
                 start = min(r.x_values) + cutoff[0]
                 end = max(r.x_values) - cutoff[1]
             keys, minvals = [], {}
             for s in self.orig_series:
                 k = s['data']
                 keys.append(k)
                 if s.get('combine_mode', None) == 'span' and k in r:
                     minvals[k] = min(
                         [d for d in r.series(k) if d is not None])
                 else:
                     minvals[k] = None
             for p in r.zipped(keys):
                 if cutoff is None or (p[0] > start and p[0] < end):
                     dp = {}
                     for k, v in zip(keys, p[1:]):
                         if minvals[k] is None:
                             dp[k] = v
                         elif v is not None:
                             dp[k] = v - minvals[k]
                         else:
                             pass  # skip None-values when a minval exists
                     res.append_datapoint(x, dp)
                     x += 1
         new_results.append(res)
     return new_results
Пример #2
0
    def group(self, groups, config):
        assert len(config['series']) == 1
        series_names = []
        group_names = []
        old_s = config['series'][0]
        for k in groups.keys():
            s, g = k.rsplit("-", 1)
            if s not in series_names:
                series_names.append(s)
            if g not in group_names:
                group_names.append(g)
        new_series = [{'data': s, 'label': s} for s in series_names]
        new_results = []
        for s in group_names:
            res = ResultSet(TITLE=s, NAME=self.orig_name)
            res.create_series(series_names)
            x = 0
            for d in zip_longest(*[g[1] for g in groups.items()
                                   if g[0].endswith("-%s" % s)]):
                data = {}
                for k, v in zip([k.rsplit("-", 1)[0] for k in groups.keys()
                                 if k.endswith("-%s" % s)], d):
                    reducer = self.get_reducer(old_s)
                    data[k] = reducer(v, old_s) if v is not None else None

                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        config['series'] = new_series

        return new_results
Пример #3
0
 def group(self, groups, config):
     new_results = []
     for k in groups.keys():
         title = "%s (n=%d)" % (k, len(groups[k])) if self.print_n else k
         res = ResultSet(TITLE=title, NAME=self.orig_name)
         res.create_series([s['data'] for s in self.orig_series])
         cutoff = config.get('cutoff', None)
         x = 0
         for r in groups[k]:
             if cutoff:
                 start = min(r.x_values) + cutoff[0]
                 end = min(r.x_values) + r.meta("TOTAL_LENGTH") - cutoff[1]
             keys, minvals = [], {}
             for s in self.orig_series:
                 k = s['data']
                 keys.append(k)
                 if s.get('combine_mode', None) == 'span' and k in r:
                     minvals[k] = min(
                         [d for d in r.series(k) if d is not None])
                 else:
                     minvals[k] = None
             for p in r.zipped(keys):
                 if cutoff is None or (p[0] > start and p[0] < end):
                     dp = {}
                     for k, v in zip(keys, p[1:]):
                         if minvals[k] is None:
                             dp[k] = v
                         elif v is not None:
                             dp[k] = v - minvals[k]
                         else:
                             pass  # skip None-values when a minval exists
                     res.append_datapoint(x, dp)
                     x += 1
         new_results.append(res)
     return new_results
Пример #4
0
    def group(self, groups, config):
        assert len(config['series']) == 1
        series_names = []
        group_names = []
        old_s = config['series'][0]
        for k in groups.keys():
            s, g = k.rsplit("-", 1)
            if not s in series_names:
                series_names.append(s)
            if not g in group_names:
                group_names.append(g)
        new_series = [{'data': s, 'label': s} for s in series_names]
        new_results = []
        for s in group_names:
            res = ResultSet(TITLE=s, NAME=self.orig_name)
            res.create_series(series_names)
            x = 0
            for d in zip_longest(
                    *
                [g[1] for g in groups.items() if g[0].endswith("-%s" % s)]):
                data = {}
                for k, v in zip([
                        k.rsplit("-", 1)[0]
                        for k in groups.keys() if k.endswith("-%s" % s)
                ], d):
                    reducer = self.get_reducer(old_s)
                    data[k] = reducer(v,
                                      old_s['data']) if v is not None else Non

                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        config['series'] = new_series

        return new_results
Пример #5
0
    def group(self, groups, config):
        if len(config['series']) > 1:
            raise RuntimeError("Cannot use group_by=both for plots with more "
                               "than one data series")
        series_names = []
        group_names = []
        old_s = config['series'][0]
        for k in groups.keys():
            s, g = k.rsplit("-", 1)
            if s not in series_names:
                series_names.append(s)
            if g not in group_names:
                group_names.append(g)
        new_series = [{'data': s, 'label': s} for s in series_names]
        new_results = []
        for s in group_names:
            res = ResultSet(TITLE=s, NAME=self.orig_name)
            res.create_series(series_names)
            x = 0
            for d in zip_longest(*[g[1] for g in groups.items()
                                   if g[0].endswith("-%s" % s)]):
                data = {}
                for k, v in zip([k.rsplit("-", 1)[0] for k in groups.keys()
                                 if k.endswith("-%s" % s)], d):
                    reducer = self.get_reducer(old_s)
                    data[k] = reducer(v, old_s) if v is not None else None

                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        config['series'] = new_series

        return new_results
Пример #6
0
    def group(self, groups, config):

        new_results = []

        for s in self.orig_series:
            res = ResultSet(TITLE=s.get('label'), NAME=self.orig_name)
            res.meta('label_override', s.get('label_override', False))
            res.create_series(groups.keys())
            x = 0
            for d in zip_longest(*groups.values()):
                data = {}
                for k, v in zip(groups.keys(), d):
                    reducer = self.get_reducer(s)
                    data[k] = reducer(v, s) if v is not None else None
                    if data[k] is not None and 'norm_factor' in s:
                        data[k] /= s['norm_factor']
                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        new_series = []
        for k in groups.keys():
            new_series.append({'data': k, 'label': k})
        config['series'] = new_series

        return new_results
Пример #7
0
    def group(self, groups, config):

        new_results = []

        for k in groups.keys():
            title = "%s (n=%d)" % (k, len(groups[k])) if self.print_n else k
            res = ResultSet(TITLE=title, NAME=self.orig_name)
            res.create_series([s['data'] for s in self.orig_series])
            x = 0
            for r in groups[k]:
                data = {}
                for s in self.orig_series:
                    reducer = self.get_reducer(s)
                    data[s['data']] = reducer(r, s)

                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        return new_results
Пример #8
0
    def group(self, groups, config):

        new_results = []

        for k in groups.keys():
            title = "%s (n=%d)" % (k, len(groups[k])) if self.print_n else k
            res = ResultSet(TITLE=title, NAME=self.orig_name)
            res.create_series([s['data'] for s in self.orig_series])
            x = 0
            for r in groups[k]:
                data = {}
                for s in self.orig_series:
                    reducer = self.get_reducer(s)
                    data[s['data']] = reducer(r, s['data'])

                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        return new_results
Пример #9
0
    def group(self, groups, config):

        new_results = []

        for s in self.orig_series:
            res = ResultSet(TITLE=s['label'], NAME=self.orig_name)
            res.create_series(groups.keys())
            x = 0
            for d in zip_longest(*groups.values()):
                data = {}
                for k, v in zip(groups.keys(), d):
                    reducer = self.get_reducer(s)
                    data[k] = reducer(v, s) if v is not None else None
                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        new_series = []
        for k in groups.keys():
            new_series.append({'data': k, 'label': k})
        config['series'] = new_series

        return new_results
Пример #10
0
    def group(self, groups, config):

        new_results = []

        for s in self.orig_series:
            res = ResultSet(TITLE=s['label'], NAME=self.orig_name)
            res.create_series(groups.keys())
            x = 0
            for d in zip_longest(*groups.values()):
                data = {}
                for k, v in zip(groups.keys(), d):
                    reducer = self.get_reducer(s)
                    data[k] = reducer(v, s['data']) if v is not None else Non
                res.append_datapoint(x, data)
                x += 1
            new_results.append(res)
        new_series = []
        for k in groups.keys():
            new_series.append({'data': k, 'label': k})
        config['series'] = new_series

        return new_results
Пример #11
0
    def group(self, groups, config):

        new_results = []

        for k in groups.keys():
            title = "%s (n=%d)" % (k, len(groups[k])) if self.print_n else k
            res = ResultSet(TITLE=title, NAME=self.orig_name)
            res.create_series([s['data'] for s in self.orig_series])
            x = 0
            orig_n = {s['data']: [] for s in self.orig_series}
            for r in groups[k]:
                data = {}
                for s in self.orig_series:
                    reducer = self.get_reducer(s)
                    data[s['data']] = reducer(r, s)
                    orig_n[s['data']].append(reducer.N)

                res.append_datapoint(x, data)
                x += 1
            for k, v in orig_n.items():
                res.series_meta(k, 'orig_n', v)
            new_results.append(res)
        return new_results