econ-ark / BayerLuetticke

12 stars 14 forks source link

Update to work with python 3.8, HARK 0.10.9 #5

Closed llorracc closed 3 years ago

llorracc commented 3 years ago

time.clock -> time.time, remove outdated test for magics

llorracc commented 3 years ago

The code snippet below, which was created long ago so that the .py files created by jupytext could be run directly from the command line via python [filename].py, now generates an error. The notebook runs fine without it. I've searched and that text is scattered throughout notebooks in many places, from which it should probably be removed if it is no longer needed for the original purpose.

One puzzle, though, is that the exact same notebook worked fine when launched with myBinder via econ-ark.org.

@MridulS, could you propose what we should do about this? Options include:

  1. Remove the code snippet everywhere, because it is no longer needed (will the .py files now run correctly without it from the command line)?
  2. Update the code snippet everywhere so it works again
  3. Something else ...
# Determine whether to make the figures inline (for spyder or jupyter)
# vs whatever is the automatic setting that will apply if run from the terminal
if in_ipynb():
    %matplotlib inline generates a syntax error when run from the shell
    # so do this instead
    get_ipython().run_line_magic('matplotlib', 'inline') 
else:
    get_ipython().run_line_magic('matplotlib', 'auto') 

# Import the plot-figure library matplotlib
MridulS commented 3 years ago

I would vote to remove this from everywhere. inline has been the default backend in ipython for a long time now https://github.com/ipython/ipykernel/blob/master/docs/changelog.md#440

so unless someone is actively going about and changing the matplotlib backend it should work okay.

MridulS commented 3 years ago

Also it should be ipython [filename].py instead of python [filename].py.

llorracc commented 3 years ago

I would vote to remove this from everywhere. inline has been the default backend in ipython for a long time now https://github.com/ipython/ipykernel/blob/master/docs/changelog.md#440

Shows you how long this code has been around!

I'll remove it everywhere.

PS. You're right: ipython not python at the command line.