diff options
Diffstat (limited to 'sagemath-ipywidgets-8.patch')
-rw-r--r-- | sagemath-ipywidgets-8.patch | 489 |
1 files changed, 489 insertions, 0 deletions
diff --git a/sagemath-ipywidgets-8.patch b/sagemath-ipywidgets-8.patch new file mode 100644 index 000000000000..95357aff89dd --- /dev/null +++ b/sagemath-ipywidgets-8.patch @@ -0,0 +1,489 @@ +diff --git a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +index e65d605..d7c4d84 100644 +--- a/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py ++++ b/src/sage/combinat/cluster_algebra_quiver/cluster_seed.py +@@ -1062,7 +1062,7 @@ class ClusterSeed(SageObject): + + sage: S = ClusterSeed(['A',4]) + sage: S.interact() +- VBox(children=... ++ ...VBox(children=... + """ + return cluster_interact(self, fig_size, circular, kind='seed') + +diff --git a/src/sage/combinat/cluster_algebra_quiver/interact.py b/src/sage/combinat/cluster_algebra_quiver/interact.py +index 4e54c64..1c88e61 100644 +--- a/src/sage/combinat/cluster_algebra_quiver/interact.py ++++ b/src/sage/combinat/cluster_algebra_quiver/interact.py +@@ -27,7 +27,7 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'): + + sage: S = ClusterSeed(['A',4]) + sage: S.interact() # indirect doctest +- VBox(children=... ++ ...VBox(children=... + """ + if kind not in ['seed', 'quiver']: + raise ValueError('kind must be "seed" or "quiver"') +@@ -107,7 +107,7 @@ def cluster_interact(self, fig_size=1, circular=True, kind='seed'): + show_lastmutation.observe(refresh, 'value') + which_plot.observe(refresh, 'value') + +- mut_buttons.on_displayed(refresh) ++ mut_buttons.on_widget_constructed(refresh) + + if kind == 'seed': + top = widgets.HBox([show_seq, show_vars]) +diff --git a/src/sage/combinat/cluster_algebra_quiver/quiver.py b/src/sage/combinat/cluster_algebra_quiver/quiver.py +index 4f6e16b..14a176c 100644 +--- a/src/sage/combinat/cluster_algebra_quiver/quiver.py ++++ b/src/sage/combinat/cluster_algebra_quiver/quiver.py +@@ -699,7 +699,7 @@ class ClusterQuiver(SageObject): + + sage: S = ClusterQuiver(['A',4]) + sage: S.interact() +- VBox(children=... ++ ...VBox(children=... + """ + return cluster_interact(self, fig_size, circular, kind="quiver") + +diff --git a/src/sage/dynamics/complex_dynamics/mandel_julia.py b/src/sage/dynamics/complex_dynamics/mandel_julia.py +index 224a484..ce67274 100644 +--- a/src/sage/dynamics/complex_dynamics/mandel_julia.py ++++ b/src/sage/dynamics/complex_dynamics/mandel_julia.py +@@ -130,7 +130,7 @@ def mandelbrot_plot(f=None, **kwds): + ``interact`` to ``True``. (This is only implemented for ``z^2 + c``):: + + sage: mandelbrot_plot(interact=True) +- interactive(children=(FloatSlider(value=0.0, description='Real center', max=1.0, min=-1.0, step=1e-05), ++ ...interactive(children=(FloatSlider(value=0.0, description='Real center', max=1.0, min=-1.0, step=1e-05), + FloatSlider(value=0.0, description='Imag center', max=1.0, min=-1.0, step=1e-05), + FloatSlider(value=4.0, description='Width', max=4.0, min=1e-05, step=1e-05), + IntSlider(value=500, description='Iterations', max=1000), +@@ -144,7 +144,7 @@ def mandelbrot_plot(f=None, **kwds): + + sage: mandelbrot_plot(interact=True, x_center=-0.75, y_center=0.25, + ....: image_width=1/2, number_of_colors=75) +- interactive(children=(FloatSlider(value=-0.75, description='Real center', max=1.0, min=-1.0, step=1e-05), ++ ...interactive(children=(FloatSlider(value=-0.75, description='Real center', max=1.0, min=-1.0, step=1e-05), + FloatSlider(value=0.25, description='Imag center', max=1.0, min=-1.0, step=1e-05), + FloatSlider(value=0.5, description='Width', max=4.0, min=1e-05, step=1e-05), + IntSlider(value=500, description='Iterations', max=1000), +@@ -600,14 +600,14 @@ def julia_plot(f=None, **kwds): + the form ``f = z^2 + c``):: + + sage: julia_plot(interact=True) +- interactive(children=(FloatSlider(value=-1.0, description='Real c'... ++ ...interactive(children=(FloatSlider(value=-1.0, description='Real c'... + + :: + + sage: R.<z> = CC[] + sage: f = z^2 + 1/2 + sage: julia_plot(f,interact=True) +- interactive(children=(FloatSlider(value=0.5, description='Real c'... ++ ...interactive(children=(FloatSlider(value=0.5, description='Real c'... + + To return the Julia set of a random `c` value with (formal) cycle structure + `(2,3)`, set ``period = [2,3]``:: +diff --git a/src/sage/interacts/library.py b/src/sage/interacts/library.py +index 8166014..6a982db 100644 +--- a/src/sage/interacts/library.py ++++ b/src/sage/interacts/library.py +@@ -12,7 +12,7 @@ interactive mathlet. In the command line, it will simply return the underlying + HTML and Sage code which creates the mathlet:: + + sage: interacts.calculus.taylor_polynomial() +- Interactive function <function taylor_polynomial at ...> with 3 widgets ++ ...Interactive function <function taylor_polynomial at ...> with 3 widgets + title: HTMLText(value='<h2>Taylor polynomial</h2>') + f: EvalText(value='e^(-x)*sin(x)', description='$f(x)=$', layout=Layout(max_width='81em')) + order: SelectionSlider(description='order', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), value=1) +@@ -101,7 +101,7 @@ def library_interact( + ....: def f(n): + ....: print(n) + sage: f() # an interact appears if using the notebook, else code +- Interactive function <function f at ...> with 1 widget ++ ...Interactive function <function f at ...> with 1 widget + n: TransformIntSlider(value=5, description='n', max=15, min=-5) + + TESTS: +@@ -117,7 +117,7 @@ def library_interact( + DeprecationWarning: Use decorator factory @library_interact(widgets) instead of @library_interact without any arguments. + See https://trac.sagemath.org/33382 for details. + sage: f() # an interact appears if using the notebook, else code +- Interactive function <function f at ...> with 1 widget ++ ...Interactive function <function f at ...> with 1 widget + n: TransformIntSlider(value=5, description='n', max=15, min=-5) + + .. NOTE:: +@@ -183,7 +183,7 @@ def demo(n: int, m: int): + creates the mathlet:: + + sage: interacts.demo() +- Interactive function <function demo at ...> with 2 widgets ++ ...Interactive function <function demo at ...> with 2 widgets + n: SelectionSlider(description='n', options=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), value=0) + m: SelectionSlider(description='m', options=(0, 1, 2, 3, 4, 5, 6, 7, 8, 9), value=0) + """ +@@ -213,7 +213,7 @@ def taylor_polynomial(title, f, order: int): + creates the mathlet:: + + sage: interacts.calculus.taylor_polynomial() +- Interactive function <function taylor_polynomial at ...> with 3 widgets ++ ...Interactive function <function taylor_polynomial at ...> with 3 widgets + title: HTMLText(value='<h2>Taylor polynomial</h2>') + f: EvalText(value='e^(-x)*sin(x)', description='$f(x)=$', layout=Layout(max_width='81em')) + order: SelectionSlider(description='order', options=(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12), value=1) +@@ -259,7 +259,7 @@ def definite_integral(title, f, g, interval, x_range, selection): + creates the mathlet:: + + sage: interacts.calculus.definite_integral() +- Interactive function <function definite_integral at ...> with 6 widgets ++ ...Interactive function <function definite_integral at ...> with 6 widgets + title: HTMLText(value='<h2>Definite integral</h2>') + f: EvalText(value='3*x', description='$f(x)=$', layout=Layout(max_width='81em')) + g: EvalText(value='x^2', description='$g(x)=$', layout=Layout(max_width='81em')) +@@ -345,7 +345,7 @@ def function_derivative(title, function, x_range, y_range): + creates the mathlet:: + + sage: interacts.calculus.function_derivative() +- Interactive function <function function_derivative at ...> with 4 widgets ++ ...Interactive function <function function_derivative at ...> with 4 widgets + title: HTMLText(value='<h2>Derivative grapher</h2>') + function: EvalText(value='x^5-3*x^3+1', description='Function:', layout=Layout(max_width='81em')) + x_range: FloatRangeSlider(value=(-2.0, 2.0), description='Range (x)', max=15.0, min=-15.0) +@@ -393,7 +393,7 @@ def difference_quotient(title, f, interval, a, x0): + creates the mathlet:: + + sage: interacts.calculus.difference_quotient() +- Interactive function <function difference_quotient at ...> with 5 widgets ++ ...Interactive function <function difference_quotient at ...> with 5 widgets + title: HTMLText(value='<h2>Difference quotient</h2>') + f: EvalText(value='sin(x)', description='f(x)', layout=Layout(max_width='81em')) + interval: FloatRangeSlider(value=(0.0, 10.0), description='Range', max=10.0) +@@ -458,7 +458,7 @@ def quadratic_equation(A, B, C): + creates the mathlet:: + + sage: interacts.calculus.quadratic_equation() +- Interactive function <function quadratic_equation at ...> with 3 widgets ++ ...Interactive function <function quadratic_equation at ...> with 3 widgets + A: IntSlider(value=1, description='A', max=7, min=-7) + B: IntSlider(value=1, description='B', max=7, min=-7) + C: IntSlider(value=-2, description='C', max=7, min=-7) +@@ -520,7 +520,7 @@ def trigonometric_properties_triangle(a0, a1, a2): + creates the mathlet:: + + sage: interacts.geometry.trigonometric_properties_triangle() +- Interactive function <function trigonometric_properties_triangle at ...> with 3 widgets ++ ...Interactive function <function trigonometric_properties_triangle at ...> with 3 widgets + a0: IntSlider(value=30, description='A', max=360) + a1: IntSlider(value=180, description='B', max=360) + a2: IntSlider(value=300, description='C', max=360) +@@ -601,7 +601,7 @@ def unit_circle(function, x): + creates the mathlet:: + + sage: interacts.geometry.unit_circle() +- Interactive function <function unit_circle at ...> with 2 widgets ++ ...Interactive function <function unit_circle at ...> with 2 widgets + function: Dropdown(description='function', options=(('sin(x)', 0), ('cos(x)', 1), ('tan(x)', 2)), value=0) + x: TransformFloatSlider(value=0.0, description='x', max=6.283185307179586, step=0.015707963267948967) + """ +@@ -702,7 +702,7 @@ def special_points( + creates the mathlet:: + + sage: interacts.geometry.special_points() +- Interactive function <function special_points at ...> with 10 widgets ++ ...Interactive function <function special_points at ...> with 10 widgets + title: HTMLText(value='<h2>Special points in triangle</h2>') + a0: IntSlider(value=30, description='A', max=360) + a1: IntSlider(value=180, description='B', max=360) +@@ -875,7 +875,7 @@ def coin(n, interval): + creates the mathlet:: + + sage: interacts.statistics.coin() +- Interactive function <function coin at ...> with 2 widgets ++ ...Interactive function <function coin at ...> with 2 widgets + n: IntSlider(value=1000, description='Number of Tosses', max=10000, min=2, step=100) + interval: IntRangeSlider(value=(0, 0), description='Plotting range (y)', max=1) + """ +@@ -915,7 +915,7 @@ def bisection_method(title, f, interval, d, maxn): + creates the mathlet:: + + sage: interacts.calculus.secant_method() +- Interactive function <function secant_method at ...> with 5 widgets ++ ...Interactive function <function secant_method at ...> with 5 widgets + title: HTMLText(value='<h2>Secant method for numerical root finding</h2>') + f: EvalText(value='x^2-2', description='f(x)', layout=Layout(max_width='81em')) + interval: IntRangeSlider(value=(0, 4), description='range', max=5, min=-5) +@@ -995,7 +995,7 @@ def secant_method(title, f, interval, d, maxn): + creates the mathlet:: + + sage: interacts.calculus.secant_method() +- Interactive function <function secant_method at ...> with 5 widgets ++ ...Interactive function <function secant_method at ...> with 5 widgets + title: HTMLText(value='<h2>Secant method for numerical root finding</h2>') + f: EvalText(value='x^2-2', description='f(x)', layout=Layout(max_width='81em')) + interval: IntRangeSlider(value=(0, 4), description='range', max=5, min=-5) +@@ -1068,7 +1068,7 @@ def newton_method(title, f, c, d, maxn, interval, list_steps): + creates the mathlet:: + + sage: interacts.calculus.newton_method() +- Interactive function <function newton_method at ...> with 7 widgets ++ ...Interactive function <function newton_method at ...> with 7 widgets + title: HTMLText(value='<h2>Newton method</h2>') + f: EvalText(value='x^2 - 2', description='f', layout=Layout(max_width='81em')) + c: IntSlider(value=6, description='Start ($x$)', max=10, min=-10) +@@ -1152,7 +1152,7 @@ def trapezoid_integration( + creates the mathlet:: + + sage: interacts.calculus.trapezoid_integration() +- Interactive function <function trapezoid_integration at ...> with 7 widgets ++ ...Interactive function <function trapezoid_integration at ...> with 7 widgets + title: HTMLText(value='<h2>Trapezoid integration</h2>') + f: EvalText(value='x^2-5*x + 10', description='$f(x)=$', layout=Layout(max_width='81em')) + n: IntSlider(value=5, description='# divisions', min=1) +@@ -1284,7 +1284,7 @@ def simpson_integration( + creates the mathlet:: + + sage: interacts.calculus.simpson_integration() +- Interactive function <function simpson_integration at ...> with 7 widgets ++ ...Interactive function <function simpson_integration at ...> with 7 widgets + title: HTMLText(value='<h2>Simpson integration</h2>') + f: EvalText(value='x*sin(x)+x+1', description='$f(x)=$', layout=Layout(max_width='81em')) + n: IntSlider(value=6, description='# divisions', min=2, step=2) +@@ -1547,7 +1547,7 @@ def function_tool(f, g, xrange, yrange, a, action, do_plot): + creates the mathlet:: + + sage: interacts.calculus.function_tool() +- Interactive function <function function_tool at ...> with 7 widgets ++ ...Interactive function <function function_tool at ...> with 7 widgets + f: EvalText(value='sin(x)', description='f') + g: EvalText(value='cos(x)', description='g') + xrange: IntRangeSlider(value=(0, 1), description='x-range', max=3, min=-3) +@@ -1677,7 +1677,7 @@ def julia(expo, c_real, c_imag, iterations, zoom_x, zoom_y, plot_points, dpi): + creates the mathlet:: + + sage: interacts.fractals.julia() +- Interactive function <function julia at ...> with 8 widgets ++ ...Interactive function <function julia at ...> with 8 widgets + expo: FloatSlider(value=2.0, description='expo', max=10.0, min=-10.0) + c_real: FloatSlider(value=0.5, description='real part const.', max=2.0, min=-2.0, step=0.01) + c_imag: FloatSlider(value=0.5, description='imag part const.', max=2.0, min=-2.0, step=0.01) +@@ -1729,7 +1729,7 @@ def mandelbrot(expo, iterations, zoom_x, zoom_y, plot_points, dpi): + creates the mathlet:: + + sage: interacts.fractals.mandelbrot() +- Interactive function <function mandelbrot at ...> with 6 widgets ++ ...Interactive function <function mandelbrot at ...> with 6 widgets + expo: FloatSlider(value=2.0, description='expo', max=10.0, min=-10.0) + iterations: IntSlider(value=20, description='# iterations', min=1) + zoom_x: FloatRangeSlider(value=(-2.0, 1.0), description='Zoom X', max=2.0, min=-2.0, step=0.01) +@@ -1774,7 +1774,7 @@ def cellular_automaton(N, rule_number, size): + creates the mathlet:: + + sage: interacts.fractals.cellular_automaton() +- Interactive function <function cellular_automaton at ...> with 3 widgets ++ ...Interactive function <function cellular_automaton at ...> with 3 widgets + N: IntSlider(value=100, description='Number of iterations', max=500, min=1) + rule_number: IntSlider(value=110, description='Rule number', max=255) + size: IntSlider(value=6, description='size of graphic', max=11, min=1) +@@ -1833,7 +1833,7 @@ def polar_prime_spiral(interval, show_factors, highlight_primes, show_curves, n, + creates the mathlet:: + + sage: sage.interacts.algebra.polar_prime_spiral() +- Interactive function <function polar_prime_spiral at ...> with 6 widgets ++ ...Interactive function <function polar_prime_spiral at ...> with 6 widgets + interval: IntRangeSlider(value=(1, 1000), description='range', max=4000, min=1, step=10) + show_factors: Checkbox(value=True, description='show_factors') + highlight_primes: Checkbox(value=True, description='highlight_primes') +diff --git a/src/sage/plot/plot3d/plot3d.py b/src/sage/plot/plot3d/plot3d.py +index 44620a0..43e1ce9 100644 +--- a/src/sage/plot/plot3d/plot3d.py ++++ b/src/sage/plot/plot3d/plot3d.py +@@ -1300,7 +1300,7 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): + sage: @interact + ....: def _(which_plot=[A,B,C,D,E]): + ....: show(which_plot) +- Interactive function <function _ at ...> with 1 widget ++ ...Interactive function <function _ at ...> with 1 widget + which_plot: Dropdown(description='which_plot', options=(Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object), value=Graphics3d Object) + + Now plot a function:: +@@ -1314,7 +1314,7 @@ def plot3d(f, urange, vrange, adaptive=False, transformation=None, **kwds): + sage: @interact + ....: def _(which_plot=[F, G, H, I, J]): + ....: show(which_plot) +- Interactive function <function _ at ...> with 1 widget ++ ...Interactive function <function _ at ...> with 1 widget + which_plot: Dropdown(description='which_plot', options=(Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object, Graphics3d Object), value=Graphics3d Object) + + TESTS: +diff --git a/src/sage/repl/display/formatter.py b/src/sage/repl/display/formatter.py +index adde08d..62bde3b 100644 +--- a/src/sage/repl/display/formatter.py ++++ b/src/sage/repl/display/formatter.py +@@ -169,8 +169,7 @@ class SageDisplayFormatter(DisplayFormatter): + sage: shell.run_cell('import ipywidgets') + sage: shell.run_cell('slider = ipywidgets.IntSlider()') + sage: shell.run_cell('get_ipython().display_formatter.format(slider)') +- IntSlider(value=0) +- ({}, {}) ++ ...IntSlider(value=0)..., {}) + + sage: shell.run_cell('%display default') + sage: shell.quit() +diff --git a/src/sage/repl/ipython_kernel/interact.py b/src/sage/repl/ipython_kernel/interact.py +index 9b94bc4..a2665a4 100644 +--- a/src/sage/repl/ipython_kernel/interact.py ++++ b/src/sage/repl/ipython_kernel/interact.py +@@ -18,7 +18,7 @@ EXAMPLES:: + sage: @interact + ....: def f(x=(0, 10)): + ....: pass +- Interactive function <function f at ...> with 1 widget ++ ...Interactive function <function f at ...> with 1 widget + x: IntSlider(value=5, description='x', max=10) + sage: f.widget.children + (IntSlider(value=5, description='x', max=10), Output()) +@@ -69,7 +69,7 @@ class sage_interactive(interactive): + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: def myfunc(x=10, y="hello", z=None): pass + sage: sage_interactive(myfunc, x=(0,100), z=["one", "two", "three"]) +- Interactive function <function myfunc at ...> with 3 widgets ++ ...Interactive function <function myfunc at ...> with 3 widgets + x: IntSlider(value=10, description='x') + y: Text(value='hello', description='y') + z: Dropdown(description='z', options=('one', 'two', 'three'), value=None) +@@ -99,10 +99,10 @@ class sage_interactive(interactive): + + sage: def myfunc(auto_update=False): pass + sage: sage_interactive(myfunc) +- Manual interactive function <function myfunc ...> with 0 widgets ++ ...Manual interactive function <function myfunc ...> with 0 widgets + sage: def myfunc(auto_update=None): pass + sage: sage_interactive(myfunc) +- Interactive function <function myfunc ...> with 0 widgets ++ ...Interactive function <function myfunc ...> with 0 widgets + """ + # Use *args to avoid name clash with keyword arguments + if len(args) < 2: +@@ -126,7 +126,7 @@ class sage_interactive(interactive): + super(sage_interactive, self).__init__(f, options, **kwds) + if self.manual: + # In Sage, manual interacts are always run once +- self.on_displayed(self.update) ++ self.on_widget_constructed(self.update) + else: + # In automatic mode, clicking on a ToggleButtons button + # should also run the interact +@@ -143,7 +143,7 @@ class sage_interactive(interactive): + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: def myfunc(): pass + sage: sage_interactive(myfunc) +- Interactive function <function myfunc ...> with 0 widgets ++ ...Interactive function <function myfunc ...> with 0 widgets + """ + s = "Manual interactive" if self.manual else "Interactive" + widgets = [w for w in self.children if isinstance(w, ValueWidget)] +@@ -164,7 +164,7 @@ class sage_interactive(interactive): + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: def myfunc(x=[1,2,3], auto_update=False): pass + sage: sage_interactive(myfunc).signature().parameters +- mappingproxy({'x': <Parameter "x=[1, 2, 3]">}) ++ ...mappingproxy({'x': <Parameter "x=[1, 2, 3]">}) + """ + return self.__signature + +@@ -181,14 +181,14 @@ class sage_interactive(interactive): + + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: sage_interactive.widget_from_single_value("sin(x)") +- Text(value='sin(x)') ++ ...Text(value='sin(x)') + sage: sage_interactive.widget_from_single_value(sin(x)) +- EvalText(value='sin(x)') ++ ...EvalText(value='sin(x)') + sage: from sage.plot.colors import Color + sage: sage_interactive.widget_from_single_value(matrix([[1, 2], [3, 4]])) +- Grid(value=[[1, 2], [3, 4]], children=(Label(value=''), VBox(children=(EvalText(value='1', layout=Layout(max_width='5em')), EvalText(value='3', layout=Layout(max_width='5em')))), VBox(children=(EvalText(value='2', layout=Layout(max_width='5em')), EvalText(value='4', layout=Layout(max_width='5em')))))) ++ ...Grid(value=[[1, 2], [3, 4]], children=(Label(value=''), VBox(children=(EvalText(value='1', layout=Layout(max_width='5em')), EvalText(value='3', layout=Layout(max_width='5em')))), VBox(children=(EvalText(value='2', layout=Layout(max_width='5em')), EvalText(value='4', layout=Layout(max_width='5em')))))) + sage: sage_interactive.widget_from_single_value(Color('cornflowerblue')) +- SageColorPicker(value='#6495ed') ++ ...SageColorPicker(value='#6495ed') + """ + # Support Sage matrices and colors + if isinstance(abbrev, Matrix): +@@ -219,15 +219,15 @@ class sage_interactive(interactive): + + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: sage_interactive.widget_from_tuple( (0, 10) ) +- IntSlider(value=5, max=10) ++ ...IntSlider(value=5, max=10) + sage: sage_interactive.widget_from_tuple( ("number", (0, 10)) ) +- IntSlider(value=5, description='number', max=10) ++ ...IntSlider(value=5, description='number', max=10) + sage: sage_interactive.widget_from_tuple( (3, (0, 10)) ) +- IntSlider(value=3, max=10) +- sage: sage_interactive.widget_from_tuple((2, dict(one=1, two=2, three=3))) +- Dropdown(index=1, options={'one': 1, 'two': 2, 'three': 3}, value=2) ++ ...IntSlider(value=3, max=10) ++ sage: sage_interactive.widget_from_tuple((2, [('one', 1), ('two', 2), ('three', 3)])) ++ ...Dropdown(index=1, options=(('one', 1), ('two', 2), ('three', 3)), value=2) + sage: sage_interactive.widget_from_tuple( (sqrt(2), pi) ) +- FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951) ++ ...FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951) + + TESTS: + +@@ -235,7 +235,7 @@ class sage_interactive(interactive): + + sage: SCR = SR.subring(no_variables=True) + sage: sage_interactive.widget_from_tuple( (SCR(sqrt(2)), SCR(pi)) ) +- FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951) ++ ...FloatSlider(value=2.277903107981444, max=3.141592653589793, min=1.4142135623730951) + """ + # Support (description, abbrev) + if len(abbrev) == 2 and isinstance(abbrev[0], str): +@@ -269,17 +269,17 @@ class sage_interactive(interactive): + + sage: from sage.repl.ipython_kernel.interact import sage_interactive + sage: sage_interactive.widget_from_iterable([1..5]) +- Dropdown(options=(1, 2, 3, 4, 5), value=1) ++ ...Dropdown(options=(1, 2, 3, 4, 5), value=1) + sage: sage_interactive.widget_from_iterable(iter([1..5])) +- SelectionSlider(options=(1, 2, 3, 4, 5), value=1) ++ ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1) + sage: sage_interactive.widget_from_iterable((1..5)) +- SelectionSlider(options=(1, 2, 3, 4, 5), value=1) ++ ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1) + sage: sage_interactive.widget_from_iterable(x for x in [1..5]) +- SelectionSlider(options=(1, 2, 3, 4, 5), value=1) ++ ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1) + sage: def gen(): + ....: yield 1; yield 2; yield 3; yield 4; yield 5 + sage: sage_interactive.widget_from_iterable(gen()) +- SelectionSlider(options=(1, 2, 3, 4, 5), value=1) ++ ...SelectionSlider(options=(1, 2, 3, 4, 5), value=1) + """ + if isinstance(abbrev, Iterator): + return SelectionSlider(options=list(abbrev)) +diff --git a/src/sage/repl/ipython_kernel/widgets_sagenb.py b/src/sage/repl/ipython_kernel/widgets_sagenb.py +index 2ce59d7..76f4f52 100644 +--- a/src/sage/repl/ipython_kernel/widgets_sagenb.py ++++ b/src/sage/repl/ipython_kernel/widgets_sagenb.py +@@ -470,15 +470,6 @@ def selector(values, label=None, default=None, nrows=None, ncols=None, width=Non + sage: selector([(1,"one"), (2,"two"), (3,"three")], buttons=True) + ToggleButtons(options=(('one', 1), ('two', 2), ('three', 3)), value=1) + +- A dict of ``label:value`` pairs is also allowed. Since a ``dict`` +- is not ordered, it is better to use an :class:`OrderedDict`:: +- +- sage: from collections import OrderedDict +- sage: selector(OrderedDict(one=1, two=2, three=3)) +- Dropdown(options=OrderedDict([('one', 1), ('two', 2), ('three', 3)]), value=1) +- sage: selector(OrderedDict(one=1, two=2, three=3), buttons=True) +- ToggleButtons(options=OrderedDict([('one', 1), ('two', 2), ('three', 3)]), value=1) +- + The values can be any kind of object: + + sage: selector([sin(x^2), GF(29), EllipticCurve('37a1')]) |