On Mon, May 4, 2009 at 12:41 PM, Robert Bradshaw <rober...@math.washington.edu> wrote: > > On May 4, 2009, at 12:22 PM, William Stein wrote: > >> On Mon, May 4, 2009 at 12:02 PM, kcrisman <kcris...@gmail.com> wrote: >>> >>> In order to plot zeta for real input, I have to do the following: >>> def Zeta(x): >>> return RR(zeta(x)) >>> plot(Zeta,2,20) >>> >>> This is because >>> sage: zeta(2) >>> 1.64493406684823 >>> sage: type(zeta(2)) >>> <type 'sage.rings.complex_number.ComplexNumber'> >>> >>> which seems odd to me that pure real complex number won't coerce to >>> the real field, or to float (which is what plot wants). >> >> This is a Python design decision. Note that in pure Python it is the >> same. Sage remains consistent with this Python design decision. >> >> sage: float(complex(1,0)) >> TypeError: can't convert complex to float; use abs(z) > > I still think this is a bad design decision that is inconsistent with > the rest of Sage and we should do differently... > > - Robert
I definitely don't claim it's a good one. I just recall that as being the justification for why things are as they are now. It would be interesting to make a list of what we consider bad design decisions in python: * len returning a Python int * float(complex(1,0)) not working Regarding the second, there is likely a really good reason why the choice to force people to use abs was made. I wonder what it is? William --~--~---------~--~----~------------~-------~--~----~ To post to this group, send email to sage-support@googlegroups.com To unsubscribe from this group, send email to sage-support-unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-support URLs: http://www.sagemath.org -~----------~----~----~----~------~----~------~--~---