Open BGerwe opened 4 years ago
I figured out the solution for my use-case by using Athena project Groups. However, I'll keep the issue open unless it is expected behavior.
To show this behavior isn't tied to anything to Athena project Groups, here's another minimal example (loosely based on #58:
import larch
from larch import Group, Interpreter
from larch import io
mylarch = Interpreter()
x = [1, 2, 3, 4]
y = [0.5, 1, 1, 0.1]
z = ['a', 'b', 'c', 'd']
g = Group('mygroup', x=x, y=y, z=z)
io.save('test.lsav', g, _larch=mylarch)
@BGerwe Yeah, saving a Project file should be easy with projectfile.save()
. And then you have a resulting file that can be easily loaded into Athena or XAS_Viewer - that would definitely be the way to go.
The io.save()
was meant to try to replace Ifeffit's save()
function, which would basically save the state of the interpreter to be reloadable. This turns out to be much harder with something as complex as Python. So, it's sort of a "known wart". I'm OK with leaving this open a nudge to do something about it - maybe remove save()
altogether or maybe "save the simple things that can be saved" (as this is almost always enough).
@newville @BGerwe doing some housekeeping with this issue, as it is relatively simple to solve. I propose to stick with Athena project files only to store/restore the state of a Larch project:
AthenaProject().save()
works correctly also outside xas_viewer
io.save()
save to Athena project fileio.restore()
restore from Athena project file
I'm not sure if this is truly a bug or my misunderstanding. For what it's worth I'm using larch 0.9.47 in JupyterLab 2.2.5 with Python 3.7.6 on Windows 10, and I have replicated this problem in both a "fresh" conda env and the base env.
When trying to save a
Group
I get the following error:A minimal example based on the Jupyter Notebook example:
Digging into the error I found that
grouplist
contains a list of tuples from_larch.symtable._sys.saverestore_groups
My ultimate goal is looping through a list of XAFS spectra, using
pre_edge
andautobk
, and then saving the results (either all together or in separate files). Maybe there is a simpler way to accomplish this?