          """ Compile trend data """
          logger.debug("Calculating Trend")
          points = len(data)
          if points < 10:
              dummy = [None for i in range(points)]
              return dummy
          x_range = range(points)
          fit = np.polyfit(x_range, data, 3)
          poly = np.poly1d(fit)
          trend = poly(x_range)
 
</s> remove         fit = np.polyfit(x_range, data, 3)
        poly = np.poly1d(fit)
        trend = poly(x_range)
 </s> add         trend = np.poly1d(np.polyfit(x_range, data, 3))(x_range) </s> remove         points = len(data)
 </s> add         points = data.shape[0] </s> remove     def calc_smoothed(self, data):
        """ Smooth the data """
        last = data[0]  # First value in the plot (first time step)
        weight = self.args["smooth_amount"]
        smoothed = list()
        for point in data:
            smoothed_val = last * weight + (1 - weight) * point  # Calculate smoothed value
            smoothed.append(smoothed_val)                        # Save it
            last = smoothed_val                                  # Anchor the last smoothed value

        return smoothed

    @staticmethod
    def calc_trend(data):
        """ Compile trend data """
 </s> add     def _calc_smoothed(self, data):
        """ Smooth the data.

        Parameters
        ----------
        data: :class:`numpy.ndarray`
            The data to smoothen

        Returns
        -------
        :class:`numpy.ndarray`
            The smoothed data
        """
        return ExponentialMovingAverage(data, self._args["smooth_amount"])()

    @classmethod
    def _calc_trend(cls, data):
        """ Calculate polynomial trend of the given data.

        Parameters
        ----------
        data: :class:`numpy.ndarray`
            The data to calculate the trend for

        Returns
        -------
        :class:`numpy.ndarray`
            The trend for the given data
        """ </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         avgs = list()
        presample = ceil(self.args["avg_samples"] / 2)
        postsample = self.args["avg_samples"] - presample
        datapoints = len(data)
 </s> add         window = self._args["avg_samples"]
        pad = ceil(window / 2)
        datapoints = data.shape[0]
            dummy = np.empty((points, ), dtype=data.dtype)
            dummy[:] = np.nan
          """ Compile trend data """
          logger.debug("Calculating Trend")
          points = len(data)
          if points < 10:
            dummy = np.empty((points, ), dtype=data.dtype)
            dummy[:] = np.nan
              return dummy
          x_range = range(points)
          fit = np.polyfit(x_range, data, 3)
          poly = np.poly1d(fit)
          trend = poly(x_range)
keep keep keep keep 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