              return
          for graph in self.subnotebook.children.values():
              graph.save_fig(graphlocation)
  
      def close(self):
          """ Clear the plots from RAM """
          self._clear_trace_variables()
          if self.subnotebook is None:
              logger.debug("No graphs to clear. Returning")
 
</s> remove         if self.trace_var is not None:
            get_config().tk_vars["smoothgraph"].trace_vdelete("w", self.trace_var)
            self.trace_var = None
 </s> add         self._clear_trace_variables() </s> remove         if self._session is None:
 </s> add         if not Session.is_loaded: </s> remove             if self.trace_var is not None:
                smooth_amount_var.trace_vdelete("w", self.trace_var)
                self.trace_var = None
 </s> add             self._clear_trace_variables() </s> remove             graph.calcs.args["smooth_amount"] = smooth_amount
 </s> add             graph.calcs.set_smooth_amount(smooth_amount)

    def _iteration_limit_callback(self, *args):
        """ Limit the amount of data displayed in the live graph on a iteration slider
        variable change. """
        try:
            limit = self.vars["display_iterations"].get()
        except tk.TclError:
            # Don't update when there is no value in the variable
            return
        logger.debug("Updating graph iteration limit: (new_value: %s, args: %s)",
                     limit, args)
        for graph in self.subnotebook.children.values():
            graph.calcs.set_iterations_limit(limit)

    def _display_data_callback(self, line, variable):
        """ Update the displayed graph lines based on option check button selection.

        Parameters
        ----------
        line: str
            The line to hide or display
        variable: :class:`tkinter.BooleanVar`
            The tkinter variable containing the ``True`` or ``False`` data for this display item
        """
        var = variable.get()
        logger.debug("Updating display %s to %s", line, var)
        for graph in self.subnotebook.children.values():
            graph.calcs.update_selections(line, var)
    def _add_trace_variables(self):
        """ Add tracing for when the option sliders are updated, for updating the graph. """
        for name, action in zip(("smoothgraph", "display_iterations"),
                                (self._smooth_amount_callback, self._iteration_limit_callback)):
            var = self.vars[name]
            if name not in self._trace_vars:
                self._trace_vars[name] = (var, var.trace("w", action))

    def _clear_trace_variables(self):
        """ Clear all of the trace variables from :attr:`_trace_vars` and reset the dictionary. """
        if self._trace_vars:
            for name, (var, trace) in self._trace_vars.items():
                logger.debug("Clearing trace from variable: %s", name)
                var.trace_vdelete("w", trace)
            self._trace_vars = dict()

              return
          for graph in self.subnotebook.children.values():
              graph.save_fig(graphlocation)
  
    def _add_trace_variables(self):
        """ Add tracing for when the option sliders are updated, for updating the graph. """
        for name, action in zip(("smoothgraph", "display_iterations"),
                                (self._smooth_amount_callback, self._iteration_limit_callback)):
            var = self.vars[name]
            if name not in self._trace_vars:
                self._trace_vars[name] = (var, var.trace("w", action))

    def _clear_trace_variables(self):
        """ Clear all of the trace variables from :attr:`_trace_vars` and reset the dictionary. """
        if self._trace_vars:
            for name, (var, trace) in self._trace_vars.items():
                logger.debug("Clearing trace from variable: %s", name)
                var.trace_vdelete("w", trace)
            self._trace_vars = dict()

      def close(self):
          """ Clear the plots from RAM """
          self._clear_trace_variables()
          if self.subnotebook is None:
              logger.debug("No graphs to clear. Returning")
keep keep keep add 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_command.py