gawseed/averageWindow.py
def add_element(self, new_element):
        """Add an element to the current slot, stored in a rotating buffer"""

        # update the total counts
        if self._middle_size > 0:
            self.lhs = self.lhs - self.lhs_data[self.index] + self.middle_data[self.middle]
            self.lhs_data[self.index] = self.middle_data[self.middle]
            self.middle_data[self.middle] = self.rhs_data[self.index]

            # update the middle index
            self.middle = self.middle + 1
            if self.middle >= self._middle_size:
                self.middle = 0

        else:
            self.lhs = self.lhs - self.lhs_data[self.index] + self.rhs_data[self.index]
            self.lhs_data[self.index] = self.rhs_data[self.index]

        # rhs side updating is always the same regardless of middle
        self.rhs = self.rhs - self.rhs_data[self.index] + new_element

        # update the array data
        self.rhs_data[self.index] = new_element

        # handle lhs and rhs index cycling
        self.index = self.index + 1
        if self.index >= self._window_size:
            self.index = 0
Add an element to the current slot, stored in a rotating buffer
Add an element to the current slot, stored in a rotating buffer
Add an element to the current slot stored in a rotating buffer
def add_element(self, new_element):
        if self._middle_size > 0:
            self.lhs = self.lhs - self.lhs_data[self.index] + self.middle_data[self.middle]
            self.lhs_data[self.index] = self.middle_data[self.middle]
            self.middle_data[self.middle] = self.rhs_data[self.index]
            self.middle = self.middle + 1
            if self.middle >= self._middle_size:
                self.middle = 0
        else:
            self.lhs = self.lhs - self.lhs_data[self.index] + self.rhs_data[self.index]
            self.lhs_data[self.index] = self.rhs_data[self.index]
        self.rhs = self.rhs - self.rhs_data[self.index] + new_element
        self.rhs_data[self.index] = new_element
        self.index = self.index + 1
        if self.index >= self._window_size:
            self.index = 0
def add_element ( self , new_element ) : if self . _middle_size > 0 : self . lhs = self . lhs - self . lhs_data [ self . index ] + self . middle_data [ self . middle ] self . lhs_data [ self . index ] = self . middle_data [ self . middle ] self . middle_data [ self . middle ] = self . rhs_data [ self . index ] self . middle = self . middle + 1 if self . middle >= self . _middle_size : self . middle = 0 else : self . lhs = self . lhs - self . lhs_data [ self . index ] + self . rhs_data [ self . index ] self . lhs_data [ self . index ] = self . rhs_data [ self . index ] self . rhs = self . rhs - self . rhs_data [ self . index ] + new_element self . rhs_data [ self . index ] = new_element self . index = self . index + 1 if self . index >= self . _window_size : self . index = 0
Add an element to the current slot, stored in a rotating buffer
Add an element to the current slot stored in a rotating buffer
"""Add an element to the current slot, stored in a rotating buffer""" # update the total counts # update the middle index # rhs side updating is always the same regardless of middle # update the array data # handle lhs and rhs index cycling
self
new_element