Here are a couple problems with those files, though I'm not getting exactly
the same problems you observe.

* You need to define the element class in the parent.  So for example,

class RingOfWittVectors(CommutativeRing):
    element_class = WittVector
    def __init__(self, base, n, p=None, category=None):

Note that I also changed parent to base, since the variable name was
misleading.

* In the __init__ method for elements,

        self._base_ring=parent

is completely wrong.  It should be

        base = parent.base_ring()
        if isinstance(data, WittVector):
            data = data._list

        if isinstance(data, (list, tuple)):
            if coerce:
                self._list = [base(a) for a in data]
            else:
                self._list = [a for a in data]
        else:
            raise NotImplementedError

There's a lot of missing functionality, but at least I can get elements to
print with these changes.
David

On Thu, May 17, 2012 at 1:40 PM, Luis Finotti <luis.fino...@gmail.com>wrote:

> Dear all,
>
> I've been working on this, following Simon King's worksheet (at
> http://flask.sagenb.org/home/pub/82) closely, but am stuck.  The files
> I am using (witt.py and witt_element.py), based on Roe and Dupuy
> previous work, are attached for your reference.
>
>
> I cannot create an element as below:
>
>
>
> t510[~/comp/witt-sage]$ sageb
> ----------------------------------------------------------------------
> | Sage Version 5.0.beta4, Release Date: 2012-02-14                   |
> | Type notebook() for the GUI, and license() for information.        |
> ----------------------------------------------------------------------
> **********************************************************************
> *                                                                    *
> * Warning: this is a prerelease version, and it may be unstable.     *
> *                                                                    *
> **********************************************************************
>
> Loading Sage library. Current Mercurial branch is:
> witt
> sage:
> R=RingOfWittVectors(GF(5),3)
> sage:
> F=GF(5)
> sage:
> w=[F(1),F(2),F(0)]
> sage: v=R(w)
> ---------------------------------------------------------------------------
> NotImplementedError                       Traceback (most recent call last)
>
> /home/finotti/comp/witt-sage/<ipython console> in <module>()
>
> /usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
> in sage.structure.parent.Parent.__call__
> (sage/structure/parent.c:7706)()
>
> NotImplementedError:
>
>
> I cannot interpret the error...
>
> I can create the element directly:
>
>
> sage: v=WittVector(w,F)
> sage: v
> _12 = [1, 2, 0]
> sage: v.length()
> _13 = 3
>
>
> One thing that does not seem to work (and I don't know why) when
> comparing with the reference above, is the following:
>
>
> sage: R.element_class
> ---------------------------------------------------------------------------
> AttributeError                            Traceback (most recent call last)
>
> /home/finotti/comp/witt-sage/<ipython console> in <module>()
>
> /usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
> in sage.structure.parent.Parent.__getattr__
> (sage/structure/parent.c:6677)()
>
> /usr/local/sage-5.0.beta4/local/lib/python2.7/site-packages/sage/structure/parent.so
> in sage.structure.parent.getattr_from_other_class
> (sage/structure/parent.c:3228)()
>
>
> AttributeError: 'RingOfWittVectors_with_category' object has no attribute
> 'element_class'
>
>
>
> On the other hand, the following works:
>
>
> sage: type(R)
> _14 = <class 'sage.rings.padics.witt.RingOfWittVectors_with_category'>
> sage:
> isinstance(R,RingOfWittVectors)
> _15 = True
> sage: isinstance(R,CommutativeRings().parent_class)
> _17 = True
>
>
> Any pointers would be greatly appreciated.
>
> Best to all,
>
>
> Luis
>
> --
> 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
>

-- 
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