Opened 6 years ago

Closed 6 years ago

#14989 closed defect (fixed)

Conversion failure from `ZZ[i]` to `CC`

Reported by: mmezzarobba Owned by:
Priority: major Milestone: sage-6.1
Component: misc Keywords:
Cc: Merged in:
Authors: Marc Mezzarobba Reviewers: Volker Braun
Report Upstream: N/A Work issues:
Branch: u/mmezzarobba/ticket/14989 Commit:
Dependencies: Stopgaps:

Description (last modified by mmezzarobba)

ComplexField_class._element_constructor_ calls x.parent().polynomial() when isinstance(x, NumberFieldElement_quadratic), but not all objects of class NumberFieldElement_quadratic have a number field as a parent. As a consequence, the following conversion (that I guess really should work, since it is suggested by pushout()) fails.

sage: QQi.<i> = NumberField(x^2+1, embedding=CC(0,1))
sage: O = QQi.order(i)
sage: from sage.categories.pushout import pushout
sage: pushout(O, CC)
Complex Field with 53 bits of precision
sage: CC(O.gen(1))
---------------------------------------------------------------------------
AttributeError                            Traceback (most recent call last)
<ipython-input-10-dbf70e6b573a> in <module>()
----> 1 CC(O.gen(Integer(1)))

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/rings/complex_field.pyc in __call__(self, x, im)
    345         if im is not None:
    346             x = x, im
--> 347         return Parent.__call__(self, x)
    348 
    349     def _element_constructor_(self, x):

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:8134)()

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3856)()

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3757)()

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/rings/complex_field.pyc in _element_constructor_(self, x)
    366 
    367             late_import()
--> 368             if isinstance(x, NumberFieldElement_quadratic) and list(x.parent().polynomial()) == [1, 0, 1]:
    369                 (re, im) = list(x)
    370                 return complex_number.ComplexNumber(self, re, im)

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__getattr__ (sage/structure/parent.c:6662)()

/home/marc/co/sage/local/lib/python2.7/site-packages/sage/structure/misc.so in sage.structure.misc.getattr_from_other_class (sage/structure/misc.c:1606)()

AttributeError: 'AbsoluteOrder_with_category' object has no attribute 'polynomial'

Change History (5)

comment:1 Changed 6 years ago by mmezzarobba

  • Branch set to u/mmezzarobba/ticket/14989
  • Description modified (diff)
  • Status changed from new to needs_review

Hmm, the example I gave in the original ticket is not correct, since it sets up an embedding into SR. But the same issue occurs with an embedding into CC. I updated the description to reflect that.

I think the linked patches solve the problem, but I have no idea if the "spirit" of the fix is right. So it would be great if someone who understands the coercion system could have a look!

comment:2 Changed 6 years ago by vbraun

  • Authors set to Marc Mezzarobba
  • Reviewers set to Volker Braun
  • Status changed from needs_review to positive_review

Thanks, looks good to me

comment:3 Changed 6 years ago by jdemeyer

  • Milestone changed from sage-5.12 to sage-6.0

comment:4 Changed 6 years ago by vbraun_spam

  • Milestone changed from sage-6.0 to sage-6.1

comment:5 Changed 6 years ago by vbraun

  • Resolution set to fixed
  • Status changed from positive_review to closed
Note: See TracTickets for help on using tickets.