Ask Your Question

interact: different behavior concerning **kwargs in SageCell an Jupyter notebook

asked 2021-04-12 01:35:24 +0200

Vitt gravatar image

I'm trying to use the output of one interact as the input for number of control elements in a second interact. The following examle code works in Sage Jupyter notebook but fails in SageCell (Unfortunately I can't post a link to SageCell due to my low karma).

I don't understand why it fails and how I can make the code run in SageCell.

def f(s=slider([1,2], default=1)):
    kwargs = { f"C_{i}": checkbox() for i in range(s)}
    def f2(**kwargs):
        for key, value in kwargs.items():
            print(f"{key} is {value}")
edit retag flag offensive close merge delete

1 Answer

Sort by ยป oldest newest most voted

answered 2021-04-12 08:23:26 +0200

vdelecroix gravatar image

(partial answer) The reason why you have different behaviors is that interact in jupyter notebook is not the same object as interact in a cell. You can check that

print(type(interact), interact.__module__)


  • <class 'ipywidgets.widgets.interaction._InteractFactory'> ipywidgets.widgets.interaction in Jupyter notebook
  • <class 'function'> interact_sagecell in the SageCell
edit flag offensive delete link more

Your Answer

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

Add Answer

Question Tools

1 follower


Asked: 2021-04-12 01:35:24 +0200

Seen: 245 times

Last updated: Apr 12 '21