Ask Your Question

# Difference of comportment between notebook and Sagecell

This command has not the same result in Sage Cells and in a notebook of sagemath 9.2. The first is the good one.

@interact(layout={'top': [['ABCD','ABDC','ACBD','ADBC','EFGH'],['BACD','BADC','BCAD','BCDA','GEFH']]})
def _(ABCD=0, ABDC=0, ACBD=0,ADBC=0,BACD=0,BADC=0,BCAD=0,BCDA=0,EFGH=0,GEFH=0):
print(ABCD+ABDC+ACBD+ACBD)


A connex question

@interact(layout={'top': [['ABCD','ABDC','ACBD','ADBC','EFGH'],['BACD','BADC','BCAD','BCDA','GEFH']]})
def _(ABCD=0, ABDC=0, ACBD=0,ADBC=0,BACD=0,BADC=0,BCAD=0,BCDA=0,EFGH=0,GEFH=0):
A = list([ABCD,ACBD,ADBC,EFGH,BACD,BADC,BCAD,BCDA,GEFH])
return A

add(_())


evaluate to 0 without waiting for input. Why ? and how to obtain the good behaviour ?

edit retag close merge delete

## 1 answer

Sort by ยป oldest newest most voted

Sage's interacts are a Sage-specific-customization of ipywidgets.interact. Their behavior is, as far as I know, documented only for the Jupyter notebook.

Ran in a 9.3.beta5 notebook, your code gives the expected result. Ran in sagecell, the presentation is cosmetically duifferent (you get number cells instead of sliders), but the result is the same (i. e. ABCD+ABDC+2*ACBD).

What did you expect exactly ?

Second question : an interact does not wait for input : it paints and activates controls, comutes the result as a functin of the (default) values of these inputs and returns it. Whenever one of the inputs changes as a result of an end-user action, the resulting value is recomputed and returned. Mos common case : the return value is a graphic, which is redisplayed.

All of this is documented and tutorialized.

sage: r.library("fortunes")
sage: r.fortune("'WTFM'")

This is all documented in TFM. Those who WTFM don't want to have to WTFM again
on the mailing list. RTFM.
-- Barry Rowlingson
R-help (October 2003)

more

## Comments

What I expect is the sagecell presentation. The idea is to help student to enter information.

( 2020-12-31 03:20:53 -0600 )edit

## Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

## Stats

Asked: 2020-12-29 16:03:45 -0600

Seen: 54 times

Last updated: Dec 30 '20