'Aggregate a list of values.
@param values: iterable of values'

def compute(self, values, method=DEFAULT, totals=False):

    if (values is None):
        return None
    if (method is DEFAULT):
        method = self.method
    if (totals and (method == 'list')):
        method = 'count'
    if ((method is None) or (method == 'list')):
        return (values if values else None)
    values = [v for v in values if (v != None)]
    if (method == 'count'):
        return len(values)
    elif (method == 'min'):
        try:
            return min(values)
        except (TypeError, ValueError):
            return None
    elif (method == 'max'):
        try:
            return max(values)
        except (TypeError, ValueError):
            return None
    elif (method == 'sum'):
        try:
            return sum(values)
        except (TypeError, ValueError):
            return None
    elif (method == 'avg'):
        try:
            if len(values):
                return (sum(values) / float(len(values)))
            else:
                return 0.0
        except (TypeError, ValueError):
            return None
    return None
