1

I'm using a Jupyter notebook (Python2 kernel) to display the results of simulations that depend on a local library mylib that I've written. In the notebook, I have

[1]  ## import library
     import mylib

[2]  ## run simulations
     X = mylib.simulateX()
     Y = mylib.simulateY()
     Z = mylib.simulateZ()

[3]  ## plot data
     mylib.disp_data([X,Y,Z])

I often find myself making changes to one of the methods, say simulateY, but wanting to retain the results of existing simulations X and Z (or even just changing disp_data). That is, I'd like to reimport my library after changing the source code of simulateY to generate newY but still have access to X and Z. Is there a way to do this without writing X and Z to a file?

jjjjjj
  • 1,152
  • 1
  • 14
  • 30

1 Answers1

2

So I think that this might autoreload magic might work for you;

import my_lib
# Use these commands in the same cell.
%load_ext autoreload
%autoreload 2
James Draper
  • 5,110
  • 5
  • 40
  • 59