Opened 9 years ago

Closed 9 years ago

#12746 closed defect (fixed)

Another coercion problem with QQbar

Reported by: davidloeffler Owned by: AlexGhitza
Priority: minor Milestone: sage-5.1
Component: algebra Keywords:
Cc: Merged in: sage-5.1.beta5
Authors: Mike Hansen Reviewers: Robert Bradshaw
Report Upstream: N/A Work issues:
Branch: Commit:
Dependencies: Stopgaps:

Description (last modified by davidloeffler)

We had a ticket recently (#12665) for QQbar(zeta(7)) . Amusingly, QQbar(zeta(6)) fails in a completely different way:

sage: QQbar(zeta(6))
ERROR: An unexpected error occurred while tokenizing input
The following traceback may be corrupted or invalid
The error message is: ('EOF in multi-line statement', (1327, 0))

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

/storage/masiao/sage-5.0.beta10/devel/sage-main/<ipython console> in <module>()

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/structure/parent.so in sage.structure.parent.Parent.__call__ (sage/structure/parent.c:7940)()

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3344)()

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/structure/coerce_maps.so in sage.structure.coerce_maps.DefaultConvertMap_unique._call_ (sage/structure/coerce_maps.c:3247)()

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/rings/qqbar.pyc in _element_constructor_(self, x)
    793             return AlgebraicNumber(x._descr)
    794         elif hasattr(x, '_algebraic_'):
--> 795             return x._algebraic_(QQbar)
    796         return AlgebraicNumber(x)
    797 

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression.so in sage.symbolic.expression.Expression._algebraic_ (sage/symbolic/expression.cpp:6286)()

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in algebraic(ex, field)
    830         0
    831     """
--> 832     return AlgebraicConverter(field)(ex)
    833 
    834 ##############

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    212                 div = self.get_fake_div(ex)
    213                 return self.arithmetic(div, div.operator())
--> 214             return self.arithmetic(ex, operator)
    215         elif operator in relation_operators:
    216             return self.relation(ex, operator)

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
    717                 return self.field(base**expt)
    718             else:
--> 719                 return reduce(operator, map(self, ex.operands()))
    720         except TypeError:
    721             if operator is _operator.pow:

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in __call__(self, ex)
    212                 div = self.get_fake_div(ex)
    213                 return self.arithmetic(div, div.operator())
--> 214             return self.arithmetic(ex, operator)
    215         elif operator in relation_operators:
    216             return self.relation(ex, operator)

/storage/masiao/sage-5.0.beta10/local/lib/python2.7/site-packages/sage/symbolic/expression_conversions.pyc in arithmetic(self, ex, operator)
    721             if operator is _operator.pow:
    722                 from sage.symbolic.constants import e, pi, I
--> 723                 base, expt = self._operands
    724                 if base == e and expt / (pi*I) in QQ:
    725                     return exp(expt)._algebraic_(self.field)

AttributeError: 'AlgebraicConverter' object has no attribute '_operands'

This is pretty minor -- the conversion is obviously absurd, and all that needs to be changed is to get it to return a more informative error message. (Amazing the bugs you can discover from a typo; when I typed QQbar(zeta(7)) it was a typo for QQbar.zeta(7) !)

Attachments (1)

trac_12746.patch (1.8 KB) - added by mhansen 9 years ago.

Download all attachments as: .zip

Change History (7)

comment:1 Changed 9 years ago by davidloeffler

  • Description modified (diff)

Changed 9 years ago by mhansen

comment:2 Changed 9 years ago by mhansen

  • Authors set to Mike Hansen
  • Status changed from new to needs_review

comment:3 Changed 9 years ago by robertwb

  • Status changed from needs_review to positive_review

Looks good to me.

comment:4 Changed 9 years ago by jdemeyer

Please fill in your real name in the Author / Reviewer fields.

comment:5 Changed 9 years ago by mhansen

  • Reviewers set to Robert Bradshaw

comment:6 Changed 9 years ago by jdemeyer

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