How to set default values ​​for IPython widgets?

I use IPython widgets to create an interactive storyline that helps students understand the determinants of accuracy of the various ODE grids available in scipy.integrate.ode . However, I can’t find much information about the various kinds of widgets and their keywords.

 from IPython.html.widgets import * @interact(h=FloatTextWidget(), atol=FloatTextWidget(), rtol=FloatTextWidget(), k=IndexSliderWidget(), integrator=TextWidget())) def plot_lotka_volterra_residuals(h=1e-1, atol=1e-3, rtol=1e-3, k=3, integrator='dopri5'): """Plots residuals of the Lotka-Volterra system.""" # make a pretty plot! 

In particular, I would like to know how to set a default value for each widget.

+5
source share
2 answers

The widget declaration accepts the keyword argument value ; you can adapt examples such as this , or try the Rossant detail Europy tutorial .

+1
source

Using ipywidgets , an instance of the management class can be passed in for interaction.

 from ipywidgets import interact, FloatSlider def update(a): print a interact(update, a=FloatSlider(min=1000., max=100000., step=1000, value=R10, description='Parameter A')) 

The GitHub repository has many great examples .

0
source

Source: https://habr.com/ru/post/1201272/


All Articles