Opened 3 years ago

Closed 3 years ago

#26206 closed defect (duplicate)

py3: problem in coercion of quotients of polynomial rings

Reported by: chapoton Owned by:
Priority: major Milestone: sage-duplicate/invalid/wontfix
Component: python3 Keywords:
Cc: embray, jdemeyer, tscrim Merged in:
Authors: Reviewers:
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Status badges

Description (last modified by chapoton)

This should be fixed by #24955

Example of file where this problem appears under python3:

sage -t src/sage/rings/polynomial/cyclotomic.pyx

File "src/sage/rings/polynomial/cyclotomic.pyx", line 270, in sage.rings.polynomial.cyclotomic.cyclotomic_value
Failed example:
    cyclotomic_value(30, t)
Exception raised:
    Traceback (most recent call last):
      File "/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/doctest/forker.py", line 650, in _run
        self.compile_and_execute(example, compiler, test.globs)
      File "/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/doctest/forker.py", line 1061, in compile_and_execute
        exec(compiled, globs)
      File "<doctest sage.rings.polynomial.cyclotomic.cyclotomic_value[13]>", line 1, in <module>
        cyclotomic_value(Integer(30), t)
      File "sage/rings/polynomial/cyclotomic.pyx", line 343, in sage.rings.polynomial.cyclotomic.cyclotomic_value (build/cythonized/sage/rings/polynomial/cyclotomic.c:6954)
        xpow = xd[j]**p
      File "sage/structure/element.pyx", line 2040, in sage.structure.element.Element.__pow__ (build/cythonized/sage/structure/element.c:14435)
        return coercion_model.bin_op(left, right, pow)
      File "sage/structure/coerce.pyx", line 1175, in sage.structure.coerce.CoercionModel_cache_maps.bin_op (build/cythonized/sage/structure/coerce.c:9762)
        return (<Action>action)._call_(x, y)
      File "sage/structure/coerce_actions.pyx", line 874, in sage.structure.coerce_actions.IntegerPowAction._call_ (build/cythonized/sage/structure/coerce_actions.c:11334)
        return e._pow_long(value)
      File "sage/structure/element.pyx", line 2117, in sage.structure.element.Element._pow_long (build/cythonized/sage/structure/element.c:15038)
        return self._pow_int(n)
      File "sage/structure/element.pyx", line 2627, in sage.structure.element.RingElement._pow_int (build/cythonized/sage/structure/element.c:18291)
        return arith_generic_power(self, n)
      File "sage/arith/power.pyx", line 83, in sage.arith.power.generic_power (build/cythonized/sage/arith/power.c:2418)
        return generic_power_long(a, value)
      File "sage/arith/power.pyx", line 102, in sage.arith.power.generic_power_long (build/cythonized/sage/arith/power.c:2705)
        return generic_power_pos(a, u)
      File "sage/arith/power.pyx", line 113, in sage.arith.power.generic_power_pos (build/cythonized/sage/arith/power.c:2786)
        apow *= apow
      File "sage/structure/element.pyx", line 1534, in sage.structure.element.Element.__mul__ (build/cythonized/sage/structure/element.c:12228)
        return (<Element>left)._mul_(right)
      File "sage/structure/element.pyx", line 2548, in sage.structure.element.RingElement._mul_ (build/cythonized/sage/structure/element.c:18023)
        cpdef _mul_(self, other):
      File "sage/categories/coercion_methods.pyx", line 53, in sage.categories.coercion_methods._mul_parent (build/cythonized/sage/categories/coercion_methods.c:2285)
        return (<Element>self)._parent.product(self, other)
      File "/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/categories/magmas.py", line 1160, in product
        return self.retract(self.lift(x) * self.lift(y))
      File "/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/rings/polynomial/polynomial_quotient_ring.py", line 595, in _coerce_impl
        return self._coerce_try(x, [self.polynomial_ring()])
      File "sage/structure/parent_old.pyx", line 278, in sage.structure.parent_old.Parent._coerce_try (build/cythonized/sage/structure/parent_old.c:5836)
        check_old_coerce(self)
      File "sage/structure/parent_old.pyx", line 43, in sage.structure.parent_old.check_old_coerce (build/cythonized/sage/structure/parent_old.c:2637)
        raise RuntimeError("%s still using old coercion framework" % p)
    RuntimeError: Univariate Quotient Polynomial Ring in t over Rational Field with modulus x^8 - x^7 + x^5 - x^4 + x^3 - x + 1 still using old coercion framework

Change History (10)

comment:1 Changed 3 years ago by chapoton

  • Summary changed from py3: problem in coercion of quotients of polynomials to py3: problem in coercion of quotients of polynomial rings

comment:2 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:3 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:4 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:5 Changed 3 years ago by chapoton

minimal failure:

sage: R.<x> = QQ[]
sage: S.<t> = R.quotient(R.cyclotomic_polynomial(3))
sage: t*t
---------------------------------------------------------------------------
RuntimeError                              Traceback (most recent call last)
<ipython-input-8-22391384ee54> in <module>()
----> 1 t*t

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/structure/element.pyx in sage.structure.element.Element.__mul__ (build/cythonized/sage/structure/element.c:12228)()
   1532         cdef int cl = classify_elements(left, right)
   1533         if HAVE_SAME_PARENT(cl):
-> 1534             return (<Element>left)._mul_(right)
   1535         if BOTH_ARE_ELEMENT(cl):
   1536             return coercion_model.bin_op(left, right, mul)

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/structure/element.pyx in sage.structure.element.RingElement._mul_ (build/cythonized/sage/structure/element.c:18023)()
   2546 
   2547 cdef class RingElement(ModuleElement):
-> 2548     cpdef _mul_(self, other):
   2549         """
   2550         Abstract multiplication method

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/categories/coercion_methods.pyx in sage.categories.coercion_methods._mul_parent (build/cythonized/sage/categories/coercion_methods.c:2285)()
     51         True
     52     """
---> 53     return (<Element>self)._parent.product(self, other)

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/categories/magmas.py in product(self, x, y)
   1158                 assert(x in self)
   1159                 assert(y in self)
-> 1160                 return self.retract(self.lift(x) * self.lift(y))
   1161 
   1162     class Realizations(RealizationsCategory):

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/rings/polynomial/polynomial_quotient_ring.py in _coerce_impl(self, x)
    593                 return self.element_class(self, self.__ring(x.lift()), check=False)
    594         # any ring that coerces to the base ring of this polynomial ring.
--> 595         return self._coerce_try(x, [self.polynomial_ring()])
    596 
    597     ############################################

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/structure/parent_old.pyx in sage.structure.parent_old.Parent._coerce_try (build/cythonized/sage/structure/parent_old.c:5836)()
    276              v -- parent object or list (iterator) of parent objects
    277         """
--> 278         check_old_coerce(self)
    279         if not isinstance(v, list):
    280             v = [v]

/home/chapoton/sage3/local/lib/python3.6/site-packages/sage/structure/parent_old.pyx in sage.structure.parent_old.check_old_coerce (build/cythonized/sage/structure/parent_old.c:2637)()
     41 cdef inline check_old_coerce(Parent p):
     42     if p._element_constructor is not None:
---> 43         raise RuntimeError("%s still using old coercion framework" % p)
     44 
     45 

RuntimeError: Univariate Quotient Polynomial Ring in t over Rational Field with modulus x^2 + x + 1 still using old coercion framework

EDIT: t._mul_?? does not give the same answer in python2 and python3.

Last edited 3 years ago by chapoton (previous) (diff)

comment:6 Changed 3 years ago by chapoton

In python3, _mul_ redirects to _mul_parent, which fails just as it fails in python2.

comment:7 Changed 3 years ago by chapoton

  • Cc embray jdemeyer tscrim added

help required, please, for this annoying coercion problem in python3.

comment:8 Changed 3 years ago by chapoton

  • Description modified (diff)
  • Status changed from new to needs_info

comment:9 Changed 3 years ago by chapoton

  • Description modified (diff)

comment:10 Changed 3 years ago by embray

  • Milestone changed from sage-8.4 to sage-duplicate/invalid/wontfix
  • Resolution set to duplicate
  • Status changed from needs_info to closed

This is really a dupe of #24955.

Note: See TracTickets for help on using tickets.