| Hi, I am trying to save intermediate step of my calculation into a file, so that next time I can read the file to resume the calculation. Say, I need to save How to save s to a file? I tried two ways: (1) Standard python module pickle cannot save sage objects, thus fails (2) I converted s to a python object: Now I can use s.save('file_name'). However, there is a bug that I cannot load using load('file_name') RuntimeError: unknown function 'a' in archive It is a known bug: http://trac.sagemath.org/sage_trac/ticket/11919 . Unfortunately I am not expert enough to fix that bug, and I really want to get my work done before waiting for the fix. Is there any other way to save the list s currently? In the bug report it is mentioned that an older version of Pynac doesn't have this bug. If there is no other work around, is it possible to downgrade Pynac within sage or I have to downgrade the whole sage? Thanks! |
| Okay, this really isn't a solution, but might serve as a temporary workaround-- you can't save formal functions, but you can convert them to maxima objects, and those can be saved. For example: So while we have we're lucky enough to have It's straightforward to bundle the above technique for these guys. Not everything can be converted seamlessly between Sage and maxima, so you might want to only convert some things, but you get the idea. |
| A partial answer: in Sage 4.7.0, the above attempt (2) works. Thus it is indeed a bug brought in from either 4.7.1 or 4.7.2. I also tried 4.8 alpha 5, the bug is not fixed --looking forward to a fix. |
Asked: Dec 15 '11
Seen: 164 times
Last updated: Dec 17 '11
powered by ASKBOT version 0.7.22
Copyright Sage, 2010. Some rights reserved under creative commons license.
I don't think it's the fact that
John Palmieri (Dec 15 '11)sis a list, it's that it contains the functionf. If you had "s = [sin(x), 12, 'hello']", you could do "save(s, 'file_name')" and then "load('file_name.sobj')" works fine.Hi, John: thanks a lot for your reply! I agree with you. But my actual goal is really want to save a list with a lot of functions like f. In my project, I start from an abstract form of a differential equation, and simplify it to a simpler form (here I want to save my work because the former step is slow, and I want to use it when I start Sage next time), and solve the differential equation with different additional conditions. It's a differential equation thus I have to define a general function instead of put a "sin(x)" in the list.
tririver (Dec 16 '11)