def get_histories_over_repetitions(self, exp, tags, aggregate):
        """ this function gets all histories of all repetitions using get_history() on the given
            tag(s), and then applies the function given by 'aggregate' to all corresponding values
            in each history over all iterations. Typical aggregate functions could be 'mean' or
            'max'.
        """
        params = self.get_params(exp)
        
        # explicitly make tags list in case of 'all'
        if tags == 'all':
            tags = self.get_history(exp, 0, 'all').keys()
        
        # make list of tags if it is just a string
        if not hasattr(tags, '__iter__'):
            tags = [tags]
         
        results = {}
        for tag in tags:
            # get all histories
            histories = zeros((params['repetitions'], params['iterations']))
            skipped = []
            for i in range(params['repetitions']):
                try:
                    histories[i, :] = self.get_history(exp, i, tag)
                except ValueError:
                    h = self.get_history(exp, i, tag)
                    if len(h) == 0:
                        # history not existent, skip it
                        print('warning: history %i has length 0 (expected: %i). it will be skipped.'%(i, params['iterations'])) 
                        skipped.append(i)
                    elif len(h) > params['iterations']:
                        # if history too long, crop it 
                        print('warning: history %i has length %i (expected: %i). it will be truncated.'%(i, len(h), params['iterations']))
                        h = h[:params['iterations']]
                        histories[i,:] = h
                    elif len(h) < params['iterations']:
                        # if history too short, crop everything else
                        print((i, len(h), params['iterations'])%'warning: history %i has length %i (expected: %i). all other histories will be truncated.')
                        params['iterations'] = len(h)
                        histories = histories[:,:params['iterations']]
                        histories[i, :] = h
            
            # remove all rows that have been skipped
            histories = delete(histories, skipped, axis=0)
            params['repetitions'] -= len(skipped)
                
            # calculate result from each column with aggregation function
            aggregated = zeros(params['iterations'])
            for i in range(params['iterations']):
                aggregated[i] = aggregate(histories[:, i])
            
            # if only one tag is requested, return list immediately, otherwise append to dictionary
            if len(tags) == 1:
                return aggregated
            else:
                results[tag] = aggregated
            
        return results
dataset/ETHPy150Open rueckstiess/expsuite/expsuite.py/PyExperimentSuite.get_histories_over_repetitions/swapped operands of `%`