#12746: Another coercion problem with QQbar
---------------------------------+------------------------------------------
       Reporter:  davidloeffler  |         Owner:  AlexGhitza
           Type:  defect         |        Status:  new       
       Priority:  minor          |     Milestone:  sage-5.0  
      Component:  algebra        |    Resolution:            
       Keywords:                 |   Work issues:            
Report Upstream:  N/A            |     Reviewers:            
        Authors:                 |     Merged in:            
   Dependencies:                 |      Stopgaps:            
---------------------------------+------------------------------------------
Description changed by davidloeffler:

Old description:

> We had a ticket recently 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) }}} !)

New description:

 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) }}} !)

--

-- 
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/12746#comment:1>
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