I'm looking for a way to reference certain cells when opening a saved notebook. That is, assume I ran some commands in a notebook, got some output, saved the notebook, then reopened it in a new kernel and wanted point to information in specific cells.
As an example let's say that I save the following notebook contents
In[1]:= f[x_]:=g[x,h[x]]
In[2]:= f[3]
Out[2]= g[3,h[3]]
In[3]:= r[x_]:=f[x]+g[x]
In[4]:= r[3]
Out[4]= g[3,h[3]]+g[3]
which I then save. Upon reopening this notebook in a new kernel, all the information of the cells will be there in the respective cells and groupings, but (as far as I can discern from the documentation) with no easy method for referencing. If I wanted the g[3,h[3]]
cell data before I closed the original kernel I could just use %2
or Out[2]
. Is there a method to achieve this relative ease of cell referencing when reopening the notebook in a new kernel?
The reason I'm looking for this sort of functionality is I want to be able to detect when the output cells differ from their saved values when re-evaluating the notebook in a new kernel. I do this to ensure that custom functions from other notebooks/packages aren't exhibiting anomalous behavior when changes are made, basically checking the newest output matches the last known "good" output.
DumpSave
? $\endgroup$DumpSave
than on theGlobal
context, please share. $\endgroup$DumpSave
, could you just saveOut
instead of the entireGlobal
context? $\endgroup$