clawpack / classic

Classic single-grid Fortran routines
http://www.clawpack.org
BSD 3-Clause "New" or "Revised" License
11 stars 25 forks source link

make plotdata an optional argument in setplot #78

Closed rjleveque closed 7 years ago

rjleveque commented 7 years ago

So you can do

import setplot
plotdata = setplot.setplot()

rather than

from clawpack.visclaw.data import ClawPlotData
plotdata = ClawPlotData()
import setplot
plotdata = setplot.setplot(plotdata)

which is handy when working in IPython or Jupyter if you want to change attributes of plotdata without modifying setplot.py.

I'll make the same change in other repositories.

I also cleaned up some inconsistencies in the headers and ugliness introduced by the Python 3 conversion.

ketch commented 7 years ago

Currently if you don't provide a setplot, you get a default setplot with some reasonable parameters. Will this break that?

(see code around line 1514 of frametools.py)

rjleveque commented 7 years ago

I only changed the definition of the setplot functions already provided, to add a default value for the plotdata argument,

def setplot(plotdata=None):

and if it's None then a ClawPlotData instance is created, and returned. But if you don't provide a setplot function then this change is moot.

rjleveque commented 7 years ago

@ketch: Maybe I interpreted your question wrong, perhaps you were asking if the default setplot or the way it is called needs to be changed?

The answer is no, since looking at line 1524 in frametools.py, the default setplot is called with a plotdata argument that was instantiated earlier in this code, and this should still behave as always.

ketch commented 7 years ago

You're right! Thanks for making it clear to me. This seems like a nice improvement.