On Tue, Nov 15, 2011 at 9:33 PM, Keshav Kini <keshav.k...@gmail.com> wrote: > Why separate it out into another function _list_plot? Why not just put a try > block into the function? That seems like it would make the source harder to > read and tracebacks longer without much benefit. It's also another matter > whether or not complex numbers being in the list are an "exceptional" > situation.
As far as I know, nobody has requested this feature in 5 years as far as I know, and at least nobody has implemented it until just now; it thus seems to be less likely to be what a random person will try to do. I therefore consider it exceptional by definition. > We currently do have if/else blocks handling the different types > of input for the list_plot function. What's so special about complex numbers > that they should be separated out with a try block and/or a wrapper > function? Not doing that way is slow, as Dan points out. Dan's question was basically: "is it possible to make this faster". I described a way that would allow for that exceptional case without any speed penalty. That's all. > What about if we just check is_ComplexNumber for things in the dataset? Is > that not enough? That's not enough -- you have to check both "is_ComplexNumber" and also for CDF: sage: is_ComplexNumber(CDF(1,1)) False I often draw plots using list_plot because it allows me to control exactly where the points are put and how many samples I take (as opposed to using the plot command, which refines). If I'm going to make 10 plots on one graph, each evaluated at several thousand points, the overhead might matter. sage: v = [(1,2)]*10^5 sage: time w = [sage.rings.complex_double.is_ComplexDoubleElement(x) or sage.rings.complex_number.is_ComplexNumber(x) for x in v] Time: CPU 0.06 s, Wall: 0.07 s OK, that's no so bad. > Should be faster than coercing them, I imagine. Coercing is really, really slow in comparison: sage: time w = [CDF(x) for x in v] Time: CPU 1.49 s, Wall: 1.49 s sage: 1.49/.07 21.2857142857143 An extra 1.5 seconds of waiting for my plot would suck. > Do we need > list_plot to be smart enough to figure out if things in the data set are any > object that could possibly be a complex number in disguise...? > > In any case, a 7 microsecond slowdown per datapoint is not a huge deal for a > point plotter, I think. If there 10^5 points that nearly a second. I do consider that a deal. -- William > > -Keshav > > ---- > Join us in #sagemath on irc.freenode.net ! > > -- > To post to this group, send an email to sage-devel@googlegroups.com > To unsubscribe from this group, send an email to > sage-devel+unsubscr...@googlegroups.com > For more options, visit this group at > http://groups.google.com/group/sage-devel > URL: http://www.sagemath.org > -- William Stein Professor of Mathematics University of Washington http://wstein.org -- To post to this group, send an email to sage-devel@googlegroups.com To unsubscribe from this group, send an email to sage-devel+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/sage-devel URL: http://www.sagemath.org