#11962: mpmath mpc won't coerce to ComplexNumber
--------------------------+-------------------------------------------------
Reporter: dsm | Owner: was
Type: defect | Status: new
Priority: major | Milestone: sage-4.7.3
Component: interfaces | Keywords:
Work_issues: | Upstream: N/A
Reviewer: | Author:
Merged: | Dependencies:
--------------------------+-------------------------------------------------
Comment(by leif):
A trivial fix would be:
{{{
#!diff
diff --git a/sage/rings/complex_number.pyx b/sage/rings/complex_number.pyx
--- a/sage/rings/complex_number.pyx
+++ b/sage/rings/complex_number.pyx
@@ -148,10 +148,11 @@
elif isinstance(real, list) or isinstance(real, tuple):
re, imag = real
real = re
- elif isinstance(real, complex):
- real, imag = real.real, real.imag
else:
- imag = 0
+ try:
+ real, imag = real.real, real.imag
+ except AttributeError:
+ imag = 0
try:
R = parent._real_field()
rr = R(real)
}}}
But perhaps there are better ways.
--
Ticket URL: <http://trac.sagemath.org/sage_trac/ticket/11962#comment:3>
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.