Return a sum term expresssion.
342941
def _sumterm(lexer):
    """"""
    xorterm = _xorterm(lexer)
    sumterm_prime = _sumterm_prime(lexer)
    if sumterm_prime is None:
        return xorterm
    else:
        return ('or', xorterm, sumterm_prime)
1164346
def sum(self, vector):
        """"""
        return self.from_list(
            [x + vector.vector[i] for i, x in self.to_list()]
        )
1219800
def get(self):
        
        if self.num is None:
            if self.num_inst == 0:
                return (self.name, float('nan'))
            else:
                return (self.name, self.sum_metric / self.num_inst)
        else:
            names = ['%s'%(self.name[i]) for i in range(self.num)]
            values = [x / y if y != 0 else float('nan') \
                for x, y in zip(self.sum_metric, self.num_inst)]
            return (names, values)
1145255
def avg(self):
        """"""
        # XXX rename this method
        if len(self.values) > 0:
            return sum(self.values) / float(len(self.values))
        else:
            return None
1001743
def sum(self):
        
        results = [x.ufuncs.sum() for x in self.elem]
        return np.sum(results)
634508
def mean(inlist):
    
    sum = 0
    for item in inlist:
        sum = sum + item
    return sum / float(len(inlist))
813249
def _sumterm_prime(lexer):
    """"""
    tok = next(lexer)
    # '|' XORTERM SUMTERM'
    if isinstance(tok, OP_or):
        xorterm = _xorterm(lexer)
        sumterm_prime = _sumterm_prime(lexer)
        if sumterm_prime is None:
            return xorterm
        else:
            return ('or', xorterm, sumterm_prime)
    # null
    else:
        lexer.unpop_token(tok)
        return None
238696
def adapt_sum(line, cfg, filter_obj):
    """"""
    lines = filter_obj.filter_all(line)
    res_s = [sum(it) for it in lines]
    r = res_s.index(min(res_s))
    return lines[r]
477888
protected Expression term() {
        Expression left = product();
        if (tokenizer.current().isSymbol("+")) {
            tokenizer.consume();
            Expression right = term();
            return reOrder(left, right, BinaryOperation.Op.ADD);
        }
        if (tokenizer.current().isSymbol("-")) {
            tokenizer.consume();
            Expression right = term();
            return reOrder(left, right, BinaryOperation.Op.SUBTRACT);
        }
        if (tokenizer.current().isNumber()) {
            if (tokenizer.current().getContents().startsWith("-")) {
                Expression right = term();
                return reOrder(left, right, BinaryOperation.Op.ADD);
            }
        }

        return left;
    }
421147
function sum(input, initial) {

    return (!isArray(input)) ? input :
        input.reduce(function(prev, curr) {
            return prev + curr;
        }, initial || 0);
}
748089
def mean(self):
        """"""
        _self = self._discard_value(None)
        if not _self.total():
            return None
        weighted_sum = sum(
            key * value for key, value in iteritems(_self)
        )
        return weighted_sum / float(_self.total())
535590
def sum_to_n(n, size, limit=None): #from http://stackoverflow.com/questions/2065553/python-get-all-numbers-that-add-up-to-a-number
    """"""
    if size == 1:
        yield [n]
        return
    if limit is None:
        limit = n
    start = (n + size - 1) // size
    stop = min(limit, n - size + 1) + 1
    for i in range(start, stop):
        for tail in sum_to_n(n - i, size - 1, i):
            yield [i] + tail
858220
def mean(data):
    """"""
    #: http://stackoverflow.com/a/27758326
    n = len(data)
    if n < 1:
        raise ValueError('mean requires at least one data point')
    return sum(data)/n
1045573
def average(sequence, key):
    """"""
    return sum(map(key, sequence)) / float(len(sequence))
1319795
def sum(cls, iresults):
        
        res = object.__new__(cls)
        res.received = []
        res.sent = 0
        for iresult in iresults:
            res.received.extend(iresult.received)
            res.sent += iresult.sent
            name = iresult.name.split('#', 1)[0]
            if hasattr(res, 'name'):
                assert res.name.split('#', 1)[0] == name, (res.name, name)
            else:
                res.name = iresult.name.split('#')[0]
        return res
673216
def sum(self):
        
        return NumpyArrayWeld(
            numpy_weld_impl.aggr(
                self.expr,
                "+",
                0,
                self.weld_type
            ),
            self.weld_type,
            0
        )
945239
def sum(self, axis=None, keepdims=False):
        
        return self.numpy().sum(axis=axis, keepdims=keepdims)