Ask Your Question

Revision history [back]

click to hide/show revision 1
initial version

The rule in Sage is to always use A.element_class, and never the original element class MyElement. In fact, they are not the same:

sage: a = A.element_class(A,{(1,):1})
sage: a
x
sage: type(a)
<class '__main__.MyAlgebra_with_category.element_class'>

This is how the category framework operates. Polynomial algebra is also optimized a lot, so its not the easiest part in Sage to understand (sorry). To construct the correct kind of polynomials you also need to override

class MyAlgebra(sage.structure.unique_representation.UniqueRepresentation, sage.rings.polynomial.multi_polynomial_ring.MPolynomialRing_polydict):
         Element=MyElement
         def _poly_class(self):
             return self.element_class