#10761: Numerical approximation of an algebraic number raises a ValueError
----------------------------+-----------------------------------------------
   Reporter:  slabbe        |       Owner:  tbd                              
       Type:  defect        |      Status:  positive_review                  
   Priority:  major         |   Milestone:  sage-4.7                         
  Component:  numerical     |    Keywords:  numerical_approx, AlgebraicNumber
     Author:  Simon Spicer  |    Upstream:  N/A                              
   Reviewer:  Rob Beezer    |      Merged:                                   
Work_issues:                |  
----------------------------+-----------------------------------------------

Comment(by kini):

 This works for me...

 {{{
 #!diff
 diff -r 361a4ad7d52c -r 87dedc409966 sage/misc/functional.py
 --- a/sage/misc/functional.py   Fri Feb 25 18:56:01 2011 +0000
 +++ b/sage/misc/functional.py   Wed Mar 23 14:18:58 2011 -0700
 @@ -1260,7 +1270,7 @@
          if not (is_ComplexNumber(x) or is_ComplexDoubleElement(x)):
              try:
                  return sage.rings.real_mpfr.RealField(prec)(x)
 -            except TypeError:
 +            except (TypeError, ValueError):
                  pass
          return sage.rings.complex_field.ComplexField(prec)(x)
 }}}

 I think it would be cleaner than just catching all exceptions. Simon, what
 exactly was wrong with catching ValueErrors?

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