Working on an implementation of free groups (ticket #12339), i have
found the following problem. I can loads-dumps free groups correctly,
but when i try to do the sme with free group elements, i get the
following error:

...
/home/mmarco/sage-5.0/local/lib/python2.7/site-packages/sage/
interfaces/expect.pyc in _check_valid(self)
   1356                 raise ValueError, "The %s session in which
this object was defined is no longer running."%P.name()
   1357         except AttributeError:
-> 1358             raise ValueError, "The session in which this
object was defined is no longer running."
   1359         return P
   1360


My class has an attribute which is a gap object, and i guess that the
problem happens there. But the same is true for the free group class.


The init of FreeGroupElement is

    def __init__(self,l=[],parent=None):
        """
        TESTS:

        ::

            sage: G=FreeGroup('a,b')
            sage: x=G([1,2,-1,-1])
            sage: x # indirect doctest
            a*b*a^-2
            sage: y=G([2,2,2,1,-2,-2,-1])
            sage: y # indirect doctest
            b^3*a*b^-2*a^-1
        """
        if parent is None:
            raise ValueError, "The parent must be provided"
        if len(l)>0:
            if (parent.rank()<max(l)) or (-parent.rank() > min(l)):
                raise ValueError, "Generators not in the group"
 
self._gap_=gap(str(l)).AbstractWordTietzeWord(parent._gap_repr_.GeneratorsOfGroup())
 
self._TietzeList_=map(Integer,list(self._gap_.TietzeWordAbstractWord()))
        Element.__init__(self,parent)


And the _init_ of FreeGroup is:

    Element=FreeGroupElement
    def __init__(self,arg1=None,arg2='x'):
        """
        TESTS:

        ::

            sage: G=FreeGroup('a,b') # indirect doctest
            sage: G
            Free Group on generators ('a', 'b')
        """
        if isinstance(arg1,int) or arg1 in IntegerRing():
            gens=normalize_names(arg1,arg2)
        else:
            gens=tuple(arg1.split(','))
        self._gens_str_=tuple(gens)
        if len(gens)==1:
            strgen='("'+gens[0]+'")'
        else:
            strgen=str(self._gens_str_).replace("'",'"')
        self._gap_repr_=gap('FreeGroup'+strgen)
 
self._gens_dict_=dict([(gens[i],self._gap_repr_.GeneratorsOfGroup()[i
+1]) for i in range(len(gens)-1)])
        group.Group.__init__(self)
        self._assign_names(gens)


Which would be the right way to implement this?

-- 
To post to this group, send an email to sage-devel@googlegroups.com
To unsubscribe from this group, send an email to 
sage-devel+unsubscr...@googlegroups.com
For more options, visit this group at http://groups.google.com/group/sage-devel
URL: http://www.sagemath.org

Reply via email to