#9429: Undesirable behaviour when deriving from QuotientRingElement
-----------------------+----------------------------------------------------
   Reporter:  vbraun   |       Owner:  AlexGhitza
       Type:  defect   |      Status:  new       
   Priority:  major    |   Milestone:            
  Component:  algebra  |    Keywords:            
     Author:           |    Upstream:  N/A       
   Reviewer:           |      Merged:            
Work_issues:           |  
-----------------------+----------------------------------------------------
 All arithmetic operations on `QuotientRingElement` return a new
 `QuotientRingElement`, which is not the desired result for derived
 classes. Instead one should use `self.__class__` to return an instance of
 the actual type:
 {{{
 sage: from sage.rings.quotient_ring_element import QuotientRingElement
 sage: class Q(QuotientRingElement):
 ...    pass
 ...
 sage: P.<x,y> = PolynomialRing(QQ, 'x, y')
 sage: Pquo = P.quo(x^3)
 sage: q = Q(Pquo, x)
 sage: type(q)
 <class '__main__.Q'>
 sage: type(q^2)
 <class 'sage.rings.quotient_ring_element.QuotientRingElement'>
 }}}

 Expected behaviour: `q^2` should have the same (derived) type as `q`.

 I am running into this issue because I want to express cohomology classes
 on toric varieties as derived classes of `QuotientRingElement`, see #9326.
 I'll write the obvious patch and attach it later today.

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/9429>
Sage <http://www.sagemath.org>
Sage: Creating a Viable Open Source Alternative to Magma, Maple, Mathematica, 
and MATLAB

-- 
You received this message because you are subscribed to the Google Groups 
"sage-trac" group.
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-trac?hl=en.

Reply via email to