Ticket #3617 (closed defect: fixed)

Opened 5 years ago

Last modified 3 years ago

LarentPolynomial.__call__ is broken for Laurent polynomial's that have negative exponents

Reported by: mhansen Owned by: malb
Priority: major Milestone: sage-4.3.2
Component: commutative algebra Keywords:
Cc: Work issues:
Report Upstream: N/A Reviewers: Sebastian Pancratz
Authors: Mike Hansen Merged in: sage-4.3.2.alpha0
Dependencies: Stopgaps:

Description

sage: P.<q> = LaurentPolynomialRing(QQ)
sage: qi = q^(-1)
sage: qi in P
False
sage: q in P
True
sage: P(qi)

---------------------------------------------------------------------------
TypeError                                 Traceback (most recent call last)

/home/mike/<ipython console> in <module>()

/opt/sage/local/lib/python2.5/site-packages/sage/rings/polynomial/laurent_polynomial_ring.py in __call__(self, x)
    679             sage: L(1/2)
    680             1/2
    681         """
--> 682         return LaurentPolynomial_mpair(self, x)
    683     

/home/mike/laurent_polynomial.pyx in sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair.__init__ (sage/rings/polynomial/laurent_polynomial.c:1889)()

/home/mike/multi_polynomial_libsingular.pyx in sage.rings.polynomial.multi_polynomial_libsingular.MPolynomialRing_libsingular.__call__ (sage/rings/polynomial/multi_polynomial_libsingular.cpp:5984)()

/opt/sage/local/lib/python2.5/site-packages/sage/rings/rational_field.py in __call__(self, x, base)
    216             return x
    217 
--> 218         return sage.rings.rational.Rational(x, base)
    219         
    220     def construction(self):

/home/mike/rational.pyx in sage.rings.rational.Rational.__init__ (sage/rings/rational.c:3321)()

/home/mike/rational.pyx in sage.rings.rational.Rational.__set_value (sage/rings/rational.c:4494)()

TypeError: Unable to coerce q^-1 (<type 'sage.rings.polynomial.laurent_polynomial.LaurentPolynomial_mpair'>) to Rational

Attachments

trac_3617.patch Download (4.1 KB) - added by mhansen 3 years ago.

Change History

comment:1 Changed 3 years ago by mhansen

  • Status changed from new to needs_review
  • Report Upstream set to N/A
  • Authors set to Mike Hansen

comment:2 Changed 3 years ago by mhansen

This also fixes #5468.

Changed 3 years ago by mhansen

comment:3 Changed 3 years ago by spancratz

  • Status changed from needs_review to positive_review

This seems fine to me, and applies and passes all doctests on 4.3.

Sebastian

comment:4 Changed 3 years ago by spancratz

  • Reviewers set to Sebastian Pancratz

comment:5 Changed 3 years ago by mvngu

  • Status changed from positive_review to closed
  • Resolution set to fixed
  • Merged in set to sage-4.3.2.alpha0
Note: See TracTickets for help on using tickets.