In Sage 5.0rc0, I observe a weird phenomenon. See the following code 
-----
from sage.rings.ring import CommutativeAlgebra

class NA(CommutativeAlgebra):
    """
    """

    def __init__(self, i):
        """
        """
        CommutativeAlgebra.__init__(self, i.base_ring())
        self._ideal = i
-----
This has no problem
-----
sage: F.<a>=GF(16)
sage: P.<x,y,z>=F[]
sage: i = P.ideal([x,y,z])
sage: NA(i)
<class '__main__.NA_with_category'>
-----
But the following modified code results in an error. The difference is the 
addition of the method "_repr_".
-----
from sage.rings.ring import CommutativeAlgebra

class NA(CommutativeAlgebra):
    """
    """

    def __init__(self, i):
        """
        """
        CommutativeAlgebra.__init__(self, i.base_ring())
        self._ideal = i

    def _repr_(self):
        return "NA defined by %s." % self._ideal  
-----
Here is the code that results in a traceback.
-----
sage: F.<a>=GF(16)
sage: P.<x,y,z>=F[]
sage: i = P.ideal([x,y,z])
sage: NA(i)
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)

/Users/kwankyu/Workplace/sage/decoders/<ipython console> in <module>()

/Users/kwankyu/Workplace/sage/decoders/<string> in __init__(self, i)

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/rings/ring.so
 
in sage.rings.ring.CommutativeAlgebra.__init__ (sage/rings/ring.c:13627)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/rings/ring.so
 
in sage.rings.ring.CommutativeRing.__init__ (sage/rings/ring.c:9574)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/rings/ring.so
 
in sage.rings.ring.Ring.__init__ (sage/rings/ring.c:1902)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/structure/parent.so
 
in sage.structure.parent.Parent.__init__ (sage/structure/parent.c:4629)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/categories/algebras.pyc
 
in __init_extra__(self)
    138             mor = None
    139             # This could be a morphism of 
Algebras(self.base_ring()); however, e.g., QQ is not in Algebras(QQ)

--> 140             H = Hom(base_ring, self, Rings())
    141 
    142             # Idea: There is a generic method "from_base_ring", 
that just does multiplication with


/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/categories/homset.pyc
 
in Hom(X, Y, category)
    157     global _cache
    158     key = (X,Y,category)
--> 159     if _cache.has_key(key):
    160         H = _cache[key]()
    161         # What is this test for? Why does the cache ever contain a 
0 value?


/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/structure/category_object.so
 
in sage.structure.category_object.CategoryObject.__hash__ 
(sage/structure/category_object.c:7329)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/structure/sage_object.so
 
in sage.structure.sage_object.SageObject.__repr__ 
(sage/structure/sage_object.c:1496)()

/Users/kwankyu/Workplace/sage/decoders/<string> in _repr_(self)

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/structure/parent.so
 
in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6732)()

/Users/kwankyu/Sage/sage-5.0.rc0/local/lib/python2.7/site-packages/sage/structure/parent.so
 
in sage.structure.parent.getattr_from_other_class 
(sage/structure/parent.c:3248)()

AttributeError: 'NA_with_category' object has no attribute '_ideal'
sage: 
-----

There is no such error in Sage 4.8 

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