Printing on SMC

53 views
Skip to first unread message

Thomas Judson

unread,
Dec 16, 2016, 1:29:09 PM12/16/16
to sage-...@googlegroups.com
The following statement prints “none” at the end of the output. I know that it is expecting an extra argument, but I can’t see what I am missing,

pretty_print(html(r"$\displaystyle\frac{dx}{dt} = %s$" % latex(f)))

Tom

William Stein

unread,
Dec 16, 2016, 1:38:59 PM12/16/16
to sage-cloud
On Fri, Dec 16, 2016 at 10:29 AM, Thomas Judson <twju...@gmail.com> wrote:
> The following statement prints “none” at the end of the output. I know that it is expecting an extra argument, but I can’t see what I am missing,
>
> pretty_print(html(r"$\displaystyle\frac{dx}{dt} = %s$" % latex(f)))

You can do this as a workaround:


html(r"$$\displaystyle\frac{dx}{dt} = %s$$" % latex(f))

However, do youwant us to change things so pretty_print(None) outputs
nothing, like sys.displayhook does? Alternatively, we could change
things so html(...) returns the empty string "" instead of returning
None. Thoughts? How are you really using this?

William

>
> Tom
>
> --
> You received this message because you are subscribed to the Google Groups "sage-cloud" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to sage-cloud+...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/sage-cloud/DB37FBDB-2886-4995-A832-F2C7AF53D2D1%40gmail.com.
> For more options, visit https://groups.google.com/d/optout.



--

Best Regards,
William Stein

CEO, SageMath, Inc.

Andrey Novoseltsev

unread,
Dec 18, 2016, 1:12:45 AM12/18/16
to sage-cloud
On Friday, 16 December 2016 11:38:59 UTC-7, William Stein wrote:
On Fri, Dec 16, 2016 at 10:29 AM, Thomas Judson <twju...@gmail.com> wrote:
> The following statement prints “none” at the end of the output.  I know that it is expecting an extra argument, but I can’t see what I am missing,
>
> pretty_print(html(r"$\displaystyle\frac{dx}{dt} = %s$"  % latex(f)))

You can do this as a workaround:


  html(r"$$\displaystyle\frac{dx}{dt} = %s$$"  % latex(f))

However, do youwant us to change things so pretty_print(None) outputs
nothing, like sys.displayhook does?    Alternatively, we could change
things so html(...) returns the empty string "" instead of returning
None.   Thoughts?  How are you really using this?

The current plan for Sage is that html(something) returns HTML representation of that something. If it is by itself, the display hook will show it appropriately. If not, there is no output, but the returned expression can be used somehow (modified or combined with other HTML fragments) and displayed later. It would be really really nice to have consistency and the behaviour is also motivated by what latex(something) does.

SageMathCell samples:
html by itself http://sagecell.sagemath.org/?z=eJzLKMnN0VAKzs9NVShJrShR0gQANkIFxA==&lang=sage
double html with the first producing a deprecation warning http://sagecell.sagemath.org/?z=eJzLKMnN0VAKzs9NVShJrShR0uTlykAXAgDbqgue&lang=sage
pretty_printed double html without any warnings http://sagecell.sagemath.org/?z=eJwrKEotKamMLyjKzCvRyCjJzdFQCs7PTVUoSa0oUdLU5OUqwK8AAP8lFqg=&lang=sage

Note also that pretty_print(None) DOES show None in a pretty way and that should be expected behaviour, I think, on the other hand if pretty_print is the last command and it itself returns None, then this None should not be shown.

Thank you,
Andrey

Thomas Judson

unread,
Dec 19, 2016, 12:42:55 PM12/19/16
to sage-cloud
I am trying to update some of the interacts from the MAA Prep workshop so that they can be included in the UTMOST Sage cell repo.  Here is an example of what I came up with:

@interact
def _(f = input_box(default=sin(x)*e^(-x)),order=slider(1,20, step_size=1), x0=("$x_0$", slider(0,4, step_size=0.25))):
    p = plot(f,(x,-1,5), thickness=2)
    ft = f.taylor(x, x0, order)
    pt = plot(ft(x),(x,-1, 5), color='green', thickness=2)
    dot = point((x0,f(x0)),pointsize=80,rgbcolor=(1,0,0))
    pretty_print(html('$f(x)\;=\;%s$'%latex(f(x))))
    pretty_print(html('$\hat{f}(x;%s)\;=\;%s+\mathcal{O}(x^{%s})$'%(x0,latex(ft(x)),order+1)))
    show(dot + p + pt, ymin = -.5, ymax = 1)
Reply all
Reply to author
Forward
0 new messages