              init_pos, pos = self.data_popup_check_boundaries(init_pos, pos)
          logger.debug("Position: %s", pos)
          return pos
  
      def data_popup_check_boundaries(self, initial_position, position):
          """ Check that the popup remains within the screen boundaries """
          logger.debug("Checking poup boundaries: (initial_position: %s, position: %s)",
                       initial_position, position)
          boundary_x = self.winfo_screenwidth() - 120
          boundary_y = self.winfo_screenheight() - 120
          if position[0] >= boundary_x or position[1] >= boundary_y:
 
</s> remove             init_pos, pos = self.data_popup_check_boundaries(init_pos, pos)
 </s> add             init_pos, pos = self._data_popup_check_boundaries(init_pos, pos) </s> remove             if pos not in self.popup_positions:
                self.popup_positions.append(pos)
 </s> add             if pos not in self._popup_positions:
                self._popup_positions.append(pos) </s> remove     def data_popup_get_position(self):
        """ Get the position of the next window """
 </s> add         Returns
        -------
        list
            The [x, y] co-ordinates that the pop up window should be placed at
        """ </s> remove         for idx in range(0, datapoints):
            if idx < presample or idx >= datapoints - postsample:
                avgs.append(None)
                continue
            avg = sum(data[idx - presample:idx + postsample]) / self.args["avg_samples"]
            avgs.append(avg)
        logger.debug("Calculated Average")
 </s> add         avgs = np.cumsum(data, dtype="float64")
        avgs[window:] = avgs[window:] - avgs[:-window]
        avgs = avgs[window - 1:] / window
        avgs = np.pad(avgs, (pad, datapoints - (avgs.shape[0] + pad)), constant_values=(np.nan,))
        logger.debug("Calculated Average: shape: %s", avgs.shape) </s> remove         selected_id = self.selected_id.get()
 </s> add         selected_id = self._selected_id.get()
        model_dir, model_name = os.path.split(Session.model_filename)
    def _data_popup_check_boundaries(self, initial_position, position):
        """ Check that the popup remains within the screen boundaries.

        Parameters
        ----------
        initial_position: list
            The [x, y] position of the last displayed popup window
        position: list
            The requested [x, y] position for the new popup window

        Returns
        -------
        tuple
            The original initial_position and position, adjusted if the new window would go out of
            bounds
        """
              init_pos, pos = self.data_popup_check_boundaries(init_pos, pos)
          logger.debug("Position: %s", pos)
          return pos
  
    def _data_popup_check_boundaries(self, initial_position, position):
        """ Check that the popup remains within the screen boundaries.

        Parameters
        ----------
        initial_position: list
            The [x, y] position of the last displayed popup window
        position: list
            The requested [x, y] position for the new popup window

        Returns
        -------
        tuple
            The original initial_position and position, adjusted if the new window would go out of
            bounds
        """
    def _data_popup_check_boundaries(self, initial_position, position):
        """ Check that the popup remains within the screen boundaries.

        Parameters
        ----------
        initial_position: list
            The [x, y] position of the last displayed popup window
        position: list
            The requested [x, y] position for the new popup window

        Returns
        -------
        tuple
            The original initial_position and position, adjusted if the new window would go out of
            bounds
        """
          logger.debug("Checking poup boundaries: (initial_position: %s, position: %s)",
                       initial_position, position)
          boundary_x = self.winfo_screenwidth() - 120
          boundary_y = self.winfo_screenheight() - 120
          if position[0] >= boundary_x or position[1] >= boundary_y:
keep keep keep keep replace replace keep keep keep keep keep
 GUI - Stats optimization (#1067)

* Faster stat loading + caching

* Compress data in cache

* Optimize some calculations

* Vectorize smoothing

* stats.Calculations optimized

* Load latest training data from live iterator

* Add options to training graph 
lib/gui/display_analysis.py