%auto not automatically running code when upload notebook worksheet

19 views
Skip to first unread message

Chris Seberino

unread,
Jun 20, 2011, 11:12:33 AM6/20/11
to sage-support
I created a little worksheet called http://phil4.com/public/sage/Scientific_Notation.sws
to illustrate the problem.

The single cell with code has this...

%hide
%auto
@interact
def _(exponent=(-6..6)):
html('The Number: $%f$'%(5 * 10**exponent))
html('In Scientific Notation: $5 \cdot 10^{%d}$'%exponent)

When I upload the worksheet, the interact widget is not running. I
need to manually unhide the code to get an evaluate link I can click
on.


kcrisman

unread,
Jun 20, 2011, 11:41:43 AM6/20/11
to sage-support


On Jun 20, 11:12 am, Chris Seberino <cseber...@gmail.com> wrote:
> I created a little worksheet calledhttp://phil4.com/public/sage/Scientific_Notation.sws
This documentation is changed (FINALLY) in 4.7.1.alpha2:

Type "%auto" on a line by itself at the beginning of a cell to
automatically evaluate the cell when the worksheet is first opened.

But thanks for the reminder - this has been a nagging problem for
quite some time.

- kcrisman

Chris Seberino

unread,
Jun 20, 2011, 5:17:31 PM6/20/11
to sage-support


On Jun 20, 10:41 am, kcrisman <kcris...@gmail.com> wrote:
> Type "%auto" on a line by itself at the beginning of a cell to
> automatically evaluate the cell when the worksheet is first opened.

kcrisman

That works one one! Thanks! I made a little worksheet that %auto
still doesn't seem to work on...

http://phil4.com/public/Sci.sws

Notice you still need to unhide code and click on evaluate to get
interact widget to run.

Sincerely,

Chris

Rolf

unread,
Jun 21, 2011, 10:09:36 AM6/21/11
to sage-support
>   html('The Number: $%f$'%(5 * 10**exponent))
>   html('In Scientific Notation: $5 \cdot 10^{%d}$'%exponent)

This question may sound somehow out of place, but maybe you can offer
some help.
Where in the documentation did you find something about this fancy
notation to include variables into your html()?
An to use two variables as in

html('In Scientific Notation: ${%d} \cdot 10^{%d}$'%base%exponent)

doesn't work either.

Chris Seberino

unread,
Jun 21, 2011, 1:15:36 PM6/21/11
to sage-support

On Jun 21, 9:09 am, Rolf <kamha...@googlemail.com> wrote:
> This question may sound somehow out of place, but maybe you can offer
> some help.
> Where in the documentation did you find something about this fancy
> notation to include variables into your html()?

I found it on one of the published worksheets not in official Sage
docs. That may have been a bad thing to do. Is
html("Some string with some Latex $x^2$") valid?

"x is %d" % y is standard Python for having variables in strings.
Perhaps that is not allowed here?

The funny thing is my original code in Sci.sws works fine if you press
evaluate. The *ONLY* problem is that it will not automatically run
thanks to %auto.

Does this new version where I moved the string tricks out of html
sound better? (It still has the same problem in that it works when
you press evaluate but doesn't automatically run.)

%auto
%hide
@interact
def _(exponent=(-6..6)):
first_sentence = "The Number: $%f$" % (5 * 10**exponent)
second_sentence = "In Scientific Notation: $5 \cdot 10^{%d}$" %
exponent
html(first_sentence)
html(second_sentence)

> An to use two variables as in
>
> html('In Scientific Notation: ${%d} \cdot 10^{%d}$'%base%exponent)
>
> doesn't work either.

I didn't see that in http://phil4.com/public/Sci.sws. I'm not sure
where you saw that.

Rolf

unread,
Jun 22, 2011, 5:26:25 AM6/22/11
to sage-support
> "x is %d" % y is standard Python for having variables in strings.

Thank, that helped a lot. In Python documentation I found the
solution.

> > html('In Scientific Notation: ${%d} \cdot 10^{%d}$'%base%exponent)
>
> > doesn't work either.
>
> I didn't see that inhttp://phil4.com/public/Sci.sws. I'm not sure
> where you saw that.

In fact it is not from that worksheet. I tried to change it. See
below.

> The *ONLY* problem is that it will not automatically run
> thanks to %auto.

I have the solution to that problem though it is not as much of a
solution as rather an idea what the reason could be.
On my system the %auto command works fine if there is no comment in
front of the cell.
Please open a new worksheet and copy the following code into the first
cell.

%auto
%hide
@interact
def _(base=(1..10),exponent=(-6..6)):
html('The Number: $%f$'%(base * 10**exponent))
html('In Scientific Notation: ${%d} \cdot 10^{%d}$'%(base,
exponent))

Works with me, and you will see my enhancement to the code. The two
variable thing.

Best regards
R.

Chris Seberino

unread,
Jun 22, 2011, 11:08:03 PM6/22/11
to sage-support


On Jun 22, 4:26 am, Rolf <kamha...@googlemail.com> wrote:
> Works with me, and you will see my enhancement to the code. The two
> variable thing.

Rolf

Thanks. Does your version automatically start up when you upload the
worksheet?
Your version works like mine but doesn't start automatically for me
like mine still.

cs

Rolf

unread,
Jun 23, 2011, 12:43:09 AM6/23/11
to sage-support
> Thanks.  Does your version automatically start up when you upload the
> worksheet?

Yes, as I said it starts automatically but it must have no descriptive
comment above the cell. That is a worksheet with only one naked cell
and no description in it.
That's why I suggested to start a new worksheet from scratch.

Your worksheet (http://phil4.com/public/Sci.sws) doesn't work with me
either.

Good luck
R.

Chris Seberino

unread,
Jun 27, 2011, 6:12:40 PM6/27/11
to sage-support

> Yes, as I said it starts automatically but it must have no descriptive
> comment above the cell. That is a worksheet with only one naked cell
> and no description in it.
> That's why I suggested to start a new worksheet from scratch.

R

OK I verified your solution. I have no clue how you figured that out
but thanks!
Was this intentional? What if someone wants to have descriptive text
at the top of their worksheet? One solution is to add a blank cell
between the descriptive text and the %auto cell.

Is this going away or is this a desired thing?

Chris

Rolf

unread,
Jun 28, 2011, 1:10:52 AM6/28/11
to sage-support

> Is this going away or is this a desired thing?

I have no idea. I hope someone who coded the notebook will answer
this.

R.
Reply all
Reply to author
Forward
0 new messages