Sage: Ticket #17558: pickled function loses its args
https://trac.sagemath.org/ticket/17558
<p>
The pickle process appears to forget whether an expression is a function.
</p>
<pre class="wiki">sage: var('u_0 u_1')
(u_0, u_1)
sage: f2u = (1 - u_0).function(u_0, u_1)
sage: f2u(x,y)
-x + 1
sage: f2 = loads(dumps(f2u))
sage: f2(x,y)
---------------------------------------------------------------------------
ValueError Traceback (most recent call last)
/usr/local/src/jekyll-research/wmd_files/Selection_Gradients/maclev-2-2-adap.sage.py in <module>()
----> 1 f2(x,y)
/usr/local/sage/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression.__call__ (build/cythonized/sage/symbolic/expression.cpp:24669)()
/usr/local/sage/local/lib/python2.7/site-packages/sage/symbolic/ring.so in sage.symbolic.ring.SymbolicRing._call_element_ (build/cythonized/sage/symbolic/ring.cpp:8970)()
ValueError: the number of arguments must be less than or equal to 1
sage: f2u
(u_0, u_1) |--> -u_0 + 1
sage: f2
-u_0 + 1
</pre><p>
Since I'm using a modular program design with intermediate results in .sobj files, this (along with some other bugs I've reported) is making it inconvenient for me to work with functions...
</p>
en-usSagehttps://trac.sagemath.org/chrome/site/logo_sagemath_trac.png
https://trac.sagemath.org/ticket/17558
Trac 1.1.6wonderSat, 27 Dec 2014 23:56:13 GMT
https://trac.sagemath.org/ticket/17558#comment:1
https://trac.sagemath.org/ticket/17558#comment:1
<p>
Possibly related to <a class="new ticket" href="https://trac.sagemath.org/ticket/17503" title="defect: pickled symbolic function breaks maxima interface (new)">#17503</a> (pickled symbolic function breaks maxima interface)
</p>
TicketnbruinSun, 28 Dec 2014 02:51:20 GMT
https://trac.sagemath.org/ticket/17558#comment:2
https://trac.sagemath.org/ticket/17558#comment:2
<p>
Replying to <a class="ticket" href="https://trac.sagemath.org/ticket/17558#comment:1" title="Comment 1">wonder</a>:
</p>
<blockquote class="citation">
<p>
Possibly related to <a class="new ticket" href="https://trac.sagemath.org/ticket/17503" title="defect: pickled symbolic function breaks maxima interface (new)">#17503</a> (pickled symbolic function breaks maxima interface)
</p>
</blockquote>
<p>
Indeed, I suspect it's related in the sense that pickling of symbolic expressions seems to rely entirely one Pynac serialization and doesn't take into account the properties of the python objects involved. In particular, the difference between a callable and a normal symbolic expression seems to lie entirely in the parent:
</p>
<pre class="wiki">sage: var('u_0 u_1 x y')
(u_0, u_1, x, y)
sage: f2u = (1 - u_0).function(u_0, u_1)
sage: parent(f2u)
Callable function ring with arguments (u_0, u_1)
sage: parent(f2u(u_0,u_1))
Symbolic Ring
sage: f2u(u_0,u_1).__reduce_ex__(2) == f2u.__reduce_ex__(2) #this confirms that they pickle to the same.
True
</pre>
TicketwonderSun, 28 Dec 2014 03:11:23 GMT
https://trac.sagemath.org/ticket/17558#comment:3
https://trac.sagemath.org/ticket/17558#comment:3Ticket