(self, value)
Adds a value to the sample.

        :type value: C{int} or C{float}
        :param value: the value to be added
Adds a value to the sample.
Adds a value to the sample .
def update(self, value):
        """
        Adds a value to the sample.

        :type value: C{int} or C{float}
        :param value: the value to be added
        """
        if self.size == 0:
            return
        self._rescale_if_necessary()
        priority = self._weight(self.clock.time() - self.start_time) / random.random()
        new_counter = self.counter + 1
        self.counter = new_counter

        if new_counter <= self.size:
            self.values[priority] = value
            heapq.heappush(self.priorities, priority)
        else:
            first = heapq.heappop(self.priorities)
            if first < priority:
                if priority not in self.values:
                    self.values[priority] = value
                    heapq.heappush(self.priorities, priority)
                    while first not in self.values:
                        first = heapq.heappop(self.priorities)
                    del self.values[first]
            else:
                heapq.heappush(self.priorities, first)
def update ( self , value ) : if self . size == 0 : return self . _rescale_if_necessary ( ) priority = self . _weight ( self . clock . time ( ) - self . start_time ) / random . random ( ) new_counter = self . counter + 1 self . counter = new_counter if new_counter <= self . size : self . values [ priority ] = value heapq . heappush ( self . priorities , priority ) else : first = heapq . heappop ( self . priorities ) if first < priority : if priority not in self . values : self . values [ priority ] = value heapq . heappush ( self . priorities , priority ) while first not in self . values : first = heapq . heappop ( self . priorities ) del self . values [ first ] else : heapq . heappush ( self . priorities , first )