Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

Okay, this really isn't a solution, but might work 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:

sage: f = function('a',var('t'))
sage: parent(f)
Symbolic Ring
sage: # convert it to maxima (maxima(f) does the same thing)
sage: f._maxima_()
'a(t)
sage: # note the prefix ' now!
sage: parent(_)
Maxima_lib
sage: # convert forward and back
sage: (f._maxima_())._sage_()
a(t)
sage: # do we have equality?
sage: bool((f._maxima_())._sage_() == f)
True

So while we have

sage: loads(dumps(f))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[...]
RuntimeError: unknown function 'a' in archive

we're lucky enough to have

sage: bool(loads(dumps(f._maxima_()))._sage_() == f)
True

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.

Okay, this really isn't a solution, but might work 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:

sage: f = function('a',var('t'))
sage: parent(f)
Symbolic Ring
sage: # convert it to maxima (maxima(f) does the same thing)
sage: f._maxima_()
'a(t)
sage: # note the prefix ' now!
sage: parent(_)
Maxima_lib
sage: # convert forward and back
sage: (f._maxima_())._sage_()
a(t)
sage: # do we have equality?
sage: bool((f._maxima_())._sage_() == f)
True

So while we have

sage: loads(dumps(f))
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
[...]
RuntimeError: unknown function 'a' in archive

we're lucky enough to have

sage: bool(loads(dumps(f._maxima_()))._sage_() == f)
True

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.