Applies a rolling sum operator to the stream.

        Attributes:
             sum_attribute_index (int): The index of the attribute to sum
             (assuming tuple records).
975849
def sum(self, attribute_selector, state_keeper=None):
        
        op = Operator(
            _generate_uuid(),
            OpType.Sum,
            "Sum",
            _sum,
            other=attribute_selector,
            state_actor=state_keeper,
            num_instances=self.env.config.parallelism)
        return self.__register(op)
878243
def next(self, val):
        
        self.queue.append(val)
        return sum(self.queue) / len(self.queue)
959188
def weighted_sum(groupe, var):
    '''
    
    '''
    data = groupe[var]
    weights = groupe['pondmen']
    return (data * weights).sum()
131080
def Sum(a, axis, keep_dims):
    
    return np.sum(a, axis=axis if not isinstance(axis, np.ndarray) else tuple(axis),
                  keepdims=keep_dims),
981308
def get_indices(integers):
    
    indices = AccumDict(accum=[])  # idx -> [(start, stop), ...]
    start = 0
    for i, vals in itertools.groupby(integers):
        n = sum(1 for val in vals)
        indices[i].append((start, start + n))
        start += n
    return indices
1088819
def add(self, index):
        
        if (index - self.flush_at) < self.interval:
            return
        now = time.time()
        elapsed = now - self.lap
        elapsed_total = now - self.start
        it = index - self.flush_at
        self.lap = now
        if self.verbose:
            logger.info("iter={} {{{}}}={}[sec/{}iter] {}[sec]".format(
                index, self.name, elapsed, it, elapsed_total))
        if self.fd is not None:
            print("{} {} {} {}".format(index, elapsed,
                                       it, elapsed_total), file=self.fd)
        self.flush_at = index
1261318
def _add_to_index(self, att, val=None, pipeline=None):
        
        index = self._index_key_for(att)
        if index is None:
            return
        t, index = index
        if t == 'attribute':
            pipeline.sadd(index, self.id)
            pipeline.sadd(self.key()['_indices'], index)
        elif t == 'list':
            for i in index:
                pipeline.sadd(i, self.id)
                pipeline.sadd(self.key()['_indices'], i)
        elif t == 'sortedset':
            zindex, index = index
            pipeline.sadd(index, self.id)
            pipeline.sadd(self.key()['_indices'], index)
            descriptor = self.attributes[att]
            score = descriptor.typecast_for_storage(getattr(self, att))
            pipeline.zadd(zindex, self.id, score)
            pipeline.sadd(self.key()['_zindices'], zindex)
673216
def sum(self):
        
        return NumpyArrayWeld(
            numpy_weld_impl.aggr(
                self.expr,
                "+",
                0,
                self.weld_type
            ),
            self.weld_type,
            0
        )
502846
public static double sum(double[] a, int fromIndex, int toIndex) {
    double result = 0.0;
    for (int i = fromIndex; i < toIndex; i++) {
      result += a[i];
    }
    return result;
  }
1198713
def sum(self, property):
        
        self.__prepare()
        total = 0
        for i in self._json_data:
            total += i.get(property)

        return total
908635
def sum(self):
        
        return GroupedDataFrameWeld(
            grizzly_impl.groupby_sum(
                self.columns,
                self.column_types,
                self.grouping_columns,
                self.grouping_column_types
            ),
            self.grouping_column_names,
            self.column_names,
            self.grouping_column_types,
            self.column_types
        )
336663
def sum_obs(A):
    
    return A.sum(0).A1 if issparse(A) else np.einsum('ij -> j', A)
614452
def sum_table(records):
    
    size = len(records[0])
    result = [None] * size
    firstrec = records[0]
    for i in range(size):
        if isinstance(firstrec[i], (numbers.Number, numpy.ndarray)):
            result[i] = sum(rec[i] for rec in records)
        else:
            result[i] = 'total'
    return result
801312
private void addUpdateAttributesOperation(UpdateAttributesOperation operation) {
        if (!this.metadata.isSealedInStorage()) {
            // Only process the operation if the Segment is not sealed in Storage. If it is, then so is the Attribute Index,
            // and it means this operation has already been applied to the index.
            Map<UUID, Long> attributes = getExtendedAttributes(operation);
            if (!attributes.isEmpty()) {
                AggregatedAppendOperation aggregatedAppend = getOrCreateAggregatedAppend(this.metadata.getStorageLength(), operation.getSequenceNumber());
                aggregatedAppend.includeAttributes(attributes);
            }
        }
    }
38337
def sum(self, callback=None):
        
        if callback is None:
            return sum(self.items)

        callback = self._value_retriever(callback)

        return self.reduce(lambda result, item: (result or 0) + callback(item))
15173
def addIndex(self, index):
        
        index.setSchema(self)
        self.__indexes[index.name()] = index
430212
def reduce_sum(attrs, inputs, proto_obj):
    """"""
    new_attrs = translation_utils._fix_attribute_names(attrs, {'axes':'axis'})
    return 'sum', new_attrs, inputs