Dear Burcin,

After thorough tests, your patch works pretty well !
I have just encountered a problem with pickling (and thus the save
function).
There is a workaround by using the __repr__ function for file saving
but this requires parsing after loading.

Here is the behavior of save in sage.4.0.1 with the patch applied :

----------------------------------------------------------------------
| Sage Version 4.0.1, Release Date: 2009-06-06                       |
| Type notebook() for the GUI, and license() for information.        |
----------------------------------------------------------------------
sage: class esub(Expression):
....:     def __init__(self, parent, val):
....:         Expression.__init__(self, parent, val)
....:
sage: a=esub(SR,x)
sage: a
x
sage: save(x,"file")
sage: save(a,"file")
---------------------------------------------------------------------------
PicklingError                             Traceback (most recent call
last)

/home/fresseng/.sage/temp/nix.sciences.univ_metz.fr/24993/
_home_fresseng__sage_init_sage_0.py in <module>()

/usr/local/src/sage-4.0.1/local/lib/python2.5/site-packages/sage/
structure/sage_object.so in sage.structure.sage_object.save (sage/
structure/sage_object.c:6832)()

/usr/local/src/sage-4.0.1/local/lib/python2.5/site-packages/sage/
structure/sage_object.so in sage.structure.sage_object.SageObject.save
(sage/structure/sage_object.c:1866)()

/usr/local/src/sage-4.0.1/local/lib/python2.5/site-packages/sage/
structure/sage_object.so in
sage.structure.sage_object.SageObject.dumps (sage/structure/
sage_object.c:2080)()

PicklingError: Can't pickle <class '__main__.esub'>: attribute lookup
__main__.esub failed


In my opinion, this should work. Am I wrong ? Is there a special
method to implement in the extension class esub ?

Thanks for your help !

Nicolas

On 12 juin, 11:22, Burcin Erocal <[email protected]> wrote:
> Hi Nicolas,
>
> On Fri, 12 Jun 2009 02:09:08 -0700 (PDT)
>
> Nicolas <[email protected]> wrote:
> > Just one quick question about patches, I have just changed the
> > expression.pyx file and ran another make (which took not so much
> > time). But it does not seem to work. Is this simple way of applying
> > patch enough or do I have to go through the mercurial system ?
>
> You need to do
>
> ./sage -br
>
> From your other message:
>
> > I will try out your patch. Why do you say that does not solve my
> > problem ?
>
> You'll see that whenever you perform arithmetic on the new objects,
> you'll end up with Expression's again.
>
> < assuming the class esub was defined as in my previous message >
> sage: var('x,y,z')
> (x, y, z)
> sage: t = x * y^z
> sage: u = esub(SR, t)
> sage: u
> y^z*x
> sage: type(u)
> <class '__main__.esub'>
> sage: type(u*u)
> <type 'sage.symbolic.expression.Expression'>
>
> Let's see how far you get with the patch. I'll try to see if there is
> a simple fix to make Expression behave well w.r.t. object oriented
> design.
>
> Cheers,
> Burcin
--~--~---------~--~----~------------~-------~--~----~
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/sage-support
URLs: http://www.sagemath.org
-~----------~----~----~----~------~----~------~--~---

Reply via email to