def sum_over(self, y, x, l): if self._y is None: self._y = RingBuffer(1) self._x = RingBuffer(1) self._l = RingBufferStr(1) self._x.append(x) self._y.append(y.astype('f8')) self._l.append(l) self._num = 1. self._y._data[0] = y else: self._num += 1. self._y._data[0] = self._y._data[0] * (self._num-1)/self._num + y/self._num
def append(self, y, x, l): """Append the new data to the ringbuffers""" if(self._y is None): if(isinstance(y, numpy.ndarray)): # Make sure the image ringbuffers don't take more than # 200 MBs. The factor of 2 takes into account the fact # that the buffer is twice as big as its usable size self._maxlen = max(1, min(self._maxlen, 1024*1024*200/(2*y.nbytes))) self._y = RingBuffer(self._maxlen) if(self._x is None): self._x = RingBuffer(self._maxlen) if(self._l is None): self._l = RingBufferStr(self._maxlen) self._y.append(y) self._x.append(x) self._l.append(l)