  
      def calc_avg(self, data):
          """ Calculate rolling average """
          logger.debug("Calculating Average")
          avgs = list()
          presample = ceil(self.args["avg_samples"] / 2)
          postsample = self.args["avg_samples"] - presample
          datapoints = len(data)
  
          if datapoints <= (self.args["avg_samples"] * 2):
              logger.info("Not enough data to compile rolling average")
              return avgs
  
 
</s> remove         if datapoints <= (self.args["avg_samples"] * 2):
 </s> add         if datapoints <= (self._args["avg_samples"] * 2): </s> remove     def calc_avg(self, data):
        """ Calculate rolling average """
 </s> add         Parameters
        ----------
        data: :class:`numpy.ndarray`
            The data to calculate the moving average for

        Returns
        -------
        :class:`numpy.ndarray`
            The moving average for the given data
        """ </s> remove             return avgs
 </s> add             return np.array([], dtype="float64") </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                 self.stats[selected_key] = method(self.stats[key])
 </s> add                 self._stats[selected_key] = method(self._stats[key])

    def _calc_avg(self, data):
        """ Calculate moving average.
        window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
  
      def calc_avg(self, data):
          """ Calculate rolling average """
          logger.debug("Calculating Average")
        window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
        window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
        window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
        window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
  
          if datapoints <= (self.args["avg_samples"] * 2):
              logger.info("Not enough data to compile rolling average")
              return avgs
  
keep keep keep keep replace replace 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/stats.py