Show More
@@ -92,7 +92,7 b' def test_single_value_string():' | |||||
92 | c = interactive(f, a=a) |
|
92 | c = interactive(f, a=a) | |
93 | w = c.children[0] |
|
93 | w = c.children[0] | |
94 | check_widget(w, |
|
94 | check_widget(w, | |
95 |
cls=widgets.Text |
|
95 | cls=widgets.Text, | |
96 | description='a', |
|
96 | description='a', | |
97 | value=a, |
|
97 | value=a, | |
98 | ) |
|
98 | ) | |
@@ -102,7 +102,7 b' def test_single_value_bool():' | |||||
102 | c = interactive(f, a=a) |
|
102 | c = interactive(f, a=a) | |
103 | w = c.children[0] |
|
103 | w = c.children[0] | |
104 | check_widget(w, |
|
104 | check_widget(w, | |
105 |
cls=widgets.Checkbox |
|
105 | cls=widgets.Checkbox, | |
106 | description='a', |
|
106 | description='a', | |
107 | value=a, |
|
107 | value=a, | |
108 | ) |
|
108 | ) | |
@@ -115,7 +115,7 b' def test_single_value_dict():' | |||||
115 | c = interactive(f, d=d) |
|
115 | c = interactive(f, d=d) | |
116 | w = c.children[0] |
|
116 | w = c.children[0] | |
117 | check_widget(w, |
|
117 | check_widget(w, | |
118 |
cls=widgets.Dropdown |
|
118 | cls=widgets.Dropdown, | |
119 | description='d', |
|
119 | description='d', | |
120 | values=d, |
|
120 | values=d, | |
121 | value=next(iter(d.values())), |
|
121 | value=next(iter(d.values())), | |
@@ -126,7 +126,7 b' def test_single_value_float():' | |||||
126 | c = interactive(f, a=a) |
|
126 | c = interactive(f, a=a) | |
127 | w = c.children[0] |
|
127 | w = c.children[0] | |
128 | check_widget(w, |
|
128 | check_widget(w, | |
129 |
cls=widgets.FloatSlider |
|
129 | cls=widgets.FloatSlider, | |
130 | description='a', |
|
130 | description='a', | |
131 | value=a, |
|
131 | value=a, | |
132 | min= -a if a > 0 else 3*a, |
|
132 | min= -a if a > 0 else 3*a, | |
@@ -141,7 +141,7 b' def test_single_value_int():' | |||||
141 | nt.assert_equal(len(c.children), 1) |
|
141 | nt.assert_equal(len(c.children), 1) | |
142 | w = c.children[0] |
|
142 | w = c.children[0] | |
143 | check_widget(w, |
|
143 | check_widget(w, | |
144 |
cls=widgets.IntSlider |
|
144 | cls=widgets.IntSlider, | |
145 | description='a', |
|
145 | description='a', | |
146 | value=a, |
|
146 | value=a, | |
147 | min= -a if a > 0 else 3*a, |
|
147 | min= -a if a > 0 else 3*a, | |
@@ -159,7 +159,7 b' def test_list_tuple_2_int():' | |||||
159 | c = interactive(f, tup=(min, max), lis=[min, max]) |
|
159 | c = interactive(f, tup=(min, max), lis=[min, max]) | |
160 | nt.assert_equal(len(c.children), 2) |
|
160 | nt.assert_equal(len(c.children), 2) | |
161 | d = dict( |
|
161 | d = dict( | |
162 |
cls=widgets.IntSlider |
|
162 | cls=widgets.IntSlider, | |
163 | min=min, |
|
163 | min=min, | |
164 | max=max, |
|
164 | max=max, | |
165 | step=1, |
|
165 | step=1, | |
@@ -176,7 +176,7 b' def test_list_tuple_3_int():' | |||||
176 | c = interactive(f, tup=(min, max, step), lis=[min, max, step]) |
|
176 | c = interactive(f, tup=(min, max, step), lis=[min, max, step]) | |
177 | nt.assert_equal(len(c.children), 2) |
|
177 | nt.assert_equal(len(c.children), 2) | |
178 | d = dict( |
|
178 | d = dict( | |
179 |
cls=widgets.IntSlider |
|
179 | cls=widgets.IntSlider, | |
180 | min=min, |
|
180 | min=min, | |
181 | max=max, |
|
181 | max=max, | |
182 | step=step, |
|
182 | step=step, | |
@@ -193,7 +193,7 b' def test_list_tuple_2_float():' | |||||
193 | c = interactive(f, tup=(min, max), lis=[min, max]) |
|
193 | c = interactive(f, tup=(min, max), lis=[min, max]) | |
194 | nt.assert_equal(len(c.children), 2) |
|
194 | nt.assert_equal(len(c.children), 2) | |
195 | d = dict( |
|
195 | d = dict( | |
196 |
cls=widgets.FloatSlider |
|
196 | cls=widgets.FloatSlider, | |
197 | min=min, |
|
197 | min=min, | |
198 | max=max, |
|
198 | max=max, | |
199 | step=.1, |
|
199 | step=.1, | |
@@ -212,7 +212,7 b' def test_list_tuple_3_float():' | |||||
212 | c = interactive(f, tup=(min, max, step), lis=[min, max, step]) |
|
212 | c = interactive(f, tup=(min, max, step), lis=[min, max, step]) | |
213 | nt.assert_equal(len(c.children), 2) |
|
213 | nt.assert_equal(len(c.children), 2) | |
214 | d = dict( |
|
214 | d = dict( | |
215 |
cls=widgets.FloatSlider |
|
215 | cls=widgets.FloatSlider, | |
216 | min=min, |
|
216 | min=min, | |
217 | max=max, |
|
217 | max=max, | |
218 | step=step, |
|
218 | step=step, | |
@@ -227,7 +227,7 b' def test_list_tuple_str():' | |||||
227 | c = interactive(f, tup=tuple(values), lis=list(values)) |
|
227 | c = interactive(f, tup=tuple(values), lis=list(values)) | |
228 | nt.assert_equal(len(c.children), 2) |
|
228 | nt.assert_equal(len(c.children), 2) | |
229 | d = dict( |
|
229 | d = dict( | |
230 |
cls=widgets.Dropdown |
|
230 | cls=widgets.Dropdown, | |
231 | value=first, |
|
231 | value=first, | |
232 | values=dvalues |
|
232 | values=dvalues | |
233 | ) |
|
233 | ) | |
@@ -253,15 +253,15 b' def test_defaults():' | |||||
253 | c = interactive(f) |
|
253 | c = interactive(f) | |
254 | check_widgets(c, |
|
254 | check_widgets(c, | |
255 | n=dict( |
|
255 | n=dict( | |
256 |
cls=widgets.IntSlider |
|
256 | cls=widgets.IntSlider, | |
257 | value=10, |
|
257 | value=10, | |
258 | ), |
|
258 | ), | |
259 | f=dict( |
|
259 | f=dict( | |
260 |
cls=widgets.FloatSlider |
|
260 | cls=widgets.FloatSlider, | |
261 | value=4.5, |
|
261 | value=4.5, | |
262 | ), |
|
262 | ), | |
263 | g=dict( |
|
263 | g=dict( | |
264 |
cls=widgets.IntSlider |
|
264 | cls=widgets.IntSlider, | |
265 | value=1, |
|
265 | value=1, | |
266 | ), |
|
266 | ), | |
267 | ) |
|
267 | ) | |
@@ -274,24 +274,24 b' def test_default_values():' | |||||
274 | c = interactive(f) |
|
274 | c = interactive(f) | |
275 | check_widgets(c, |
|
275 | check_widgets(c, | |
276 | n=dict( |
|
276 | n=dict( | |
277 |
cls=widgets.IntSlider |
|
277 | cls=widgets.IntSlider, | |
278 | value=10, |
|
278 | value=10, | |
279 | ), |
|
279 | ), | |
280 | f=dict( |
|
280 | f=dict( | |
281 |
cls=widgets.FloatSlider |
|
281 | cls=widgets.FloatSlider, | |
282 | value=4.5, |
|
282 | value=4.5, | |
283 | ), |
|
283 | ), | |
284 | g=dict( |
|
284 | g=dict( | |
285 |
cls=widgets.IntSlider |
|
285 | cls=widgets.IntSlider, | |
286 | value=5, |
|
286 | value=5, | |
287 | ), |
|
287 | ), | |
288 | h=dict( |
|
288 | h=dict( | |
289 |
cls=widgets.Dropdown |
|
289 | cls=widgets.Dropdown, | |
290 | values={'a': 1, 'b': 2}, |
|
290 | values={'a': 1, 'b': 2}, | |
291 | value=2 |
|
291 | value=2 | |
292 | ), |
|
292 | ), | |
293 | j=dict( |
|
293 | j=dict( | |
294 |
cls=widgets.Dropdown |
|
294 | cls=widgets.Dropdown, | |
295 | values={'hi':'hi', 'there':'there'}, |
|
295 | values={'hi':'hi', 'there':'there'}, | |
296 | value='there' |
|
296 | value='there' | |
297 | ), |
|
297 | ), | |
@@ -305,34 +305,34 b' def test_default_out_of_bounds():' | |||||
305 | c = interactive(f) |
|
305 | c = interactive(f) | |
306 | check_widgets(c, |
|
306 | check_widgets(c, | |
307 | f=dict( |
|
307 | f=dict( | |
308 |
cls=widgets.FloatSlider |
|
308 | cls=widgets.FloatSlider, | |
309 | value=5., |
|
309 | value=5., | |
310 | ), |
|
310 | ), | |
311 | h=dict( |
|
311 | h=dict( | |
312 |
cls=widgets.Dropdown |
|
312 | cls=widgets.Dropdown, | |
313 | values={'a': 1}, |
|
313 | values={'a': 1}, | |
314 | value=1, |
|
314 | value=1, | |
315 | ), |
|
315 | ), | |
316 | j=dict( |
|
316 | j=dict( | |
317 |
cls=widgets.Dropdown |
|
317 | cls=widgets.Dropdown, | |
318 | values={'hi':'hi', 'there':'there'}, |
|
318 | values={'hi':'hi', 'there':'there'}, | |
319 | value='hi', |
|
319 | value='hi', | |
320 | ), |
|
320 | ), | |
321 | ) |
|
321 | ) | |
322 |
|
322 | |||
323 | def test_annotations(): |
|
323 | def test_annotations(): | |
324 |
@annotate(n=10, f=widgets.FloatText |
|
324 | @annotate(n=10, f=widgets.FloatText()) | |
325 | def f(n, f): |
|
325 | def f(n, f): | |
326 | pass |
|
326 | pass | |
327 |
|
327 | |||
328 | c = interactive(f) |
|
328 | c = interactive(f) | |
329 | check_widgets(c, |
|
329 | check_widgets(c, | |
330 | n=dict( |
|
330 | n=dict( | |
331 |
cls=widgets.IntSlider |
|
331 | cls=widgets.IntSlider, | |
332 | value=10, |
|
332 | value=10, | |
333 | ), |
|
333 | ), | |
334 | f=dict( |
|
334 | f=dict( | |
335 |
cls=widgets.FloatText |
|
335 | cls=widgets.FloatText, | |
336 | ), |
|
336 | ), | |
337 | ) |
|
337 | ) | |
338 |
|
338 | |||
@@ -344,11 +344,11 b' def test_priority():' | |||||
344 | c = interactive(f, kwarg='kwarg') |
|
344 | c = interactive(f, kwarg='kwarg') | |
345 | check_widgets(c, |
|
345 | check_widgets(c, | |
346 | kwarg=dict( |
|
346 | kwarg=dict( | |
347 |
cls=widgets.Text |
|
347 | cls=widgets.Text, | |
348 | value='kwarg', |
|
348 | value='kwarg', | |
349 | ), |
|
349 | ), | |
350 | annotate=dict( |
|
350 | annotate=dict( | |
351 |
cls=widgets.Text |
|
351 | cls=widgets.Text, | |
352 | value='annotate', |
|
352 | value='annotate', | |
353 | ), |
|
353 | ), | |
354 | ) |
|
354 | ) | |
@@ -362,7 +362,7 b' def test_decorator_kwarg():' | |||||
362 | nt.assert_equal(len(displayed), 1) |
|
362 | nt.assert_equal(len(displayed), 1) | |
363 | w = displayed[0].children[0] |
|
363 | w = displayed[0].children[0] | |
364 | check_widget(w, |
|
364 | check_widget(w, | |
365 |
cls=widgets.IntSlider |
|
365 | cls=widgets.IntSlider, | |
366 | value=5, |
|
366 | value=5, | |
367 | ) |
|
367 | ) | |
368 |
|
368 | |||
@@ -375,7 +375,7 b' def test_decorator_no_call():' | |||||
375 | nt.assert_equal(len(displayed), 1) |
|
375 | nt.assert_equal(len(displayed), 1) | |
376 | w = displayed[0].children[0] |
|
376 | w = displayed[0].children[0] | |
377 | check_widget(w, |
|
377 | check_widget(w, | |
378 |
cls=widgets.Text |
|
378 | cls=widgets.Text, | |
379 | value='default', |
|
379 | value='default', | |
380 | ) |
|
380 | ) | |
381 |
|
381 | |||
@@ -388,7 +388,7 b' def test_call_interact():' | |||||
388 | nt.assert_equal(len(displayed), 1) |
|
388 | nt.assert_equal(len(displayed), 1) | |
389 | w = displayed[0].children[0] |
|
389 | w = displayed[0].children[0] | |
390 | check_widget(w, |
|
390 | check_widget(w, | |
391 |
cls=widgets.Text |
|
391 | cls=widgets.Text, | |
392 | value='default', |
|
392 | value='default', | |
393 | ) |
|
393 | ) | |
394 |
|
394 | |||
@@ -401,7 +401,7 b' def test_call_interact_kwargs():' | |||||
401 | nt.assert_equal(len(displayed), 1) |
|
401 | nt.assert_equal(len(displayed), 1) | |
402 | w = displayed[0].children[0] |
|
402 | w = displayed[0].children[0] | |
403 | check_widget(w, |
|
403 | check_widget(w, | |
404 |
cls=widgets.IntSlider |
|
404 | cls=widgets.IntSlider, | |
405 | value=10, |
|
405 | value=10, | |
406 | ) |
|
406 | ) | |
407 |
|
407 | |||
@@ -417,7 +417,7 b' def test_call_decorated_on_trait_change():' | |||||
417 | nt.assert_equal(len(displayed), 1) |
|
417 | nt.assert_equal(len(displayed), 1) | |
418 | w = displayed[0].children[0] |
|
418 | w = displayed[0].children[0] | |
419 | check_widget(w, |
|
419 | check_widget(w, | |
420 |
cls=widgets.Text |
|
420 | cls=widgets.Text, | |
421 | value='default', |
|
421 | value='default', | |
422 | ) |
|
422 | ) | |
423 | # test calling the function directly |
|
423 | # test calling the function directly | |
@@ -441,7 +441,7 b' def test_call_decorated_kwargs_on_trait_change():' | |||||
441 | nt.assert_equal(len(displayed), 1) |
|
441 | nt.assert_equal(len(displayed), 1) | |
442 | w = displayed[0].children[0] |
|
442 | w = displayed[0].children[0] | |
443 | check_widget(w, |
|
443 | check_widget(w, | |
444 |
cls=widgets.Text |
|
444 | cls=widgets.Text, | |
445 | value='kwarg', |
|
445 | value='kwarg', | |
446 | ) |
|
446 | ) | |
447 | # test calling the function directly |
|
447 | # test calling the function directly | |
@@ -458,7 +458,7 b' def test_fixed():' | |||||
458 | nt.assert_equal(len(c.children), 1) |
|
458 | nt.assert_equal(len(c.children), 1) | |
459 | w = c.children[0] |
|
459 | w = c.children[0] | |
460 | check_widget(w, |
|
460 | check_widget(w, | |
461 |
cls=widgets.Text |
|
461 | cls=widgets.Text, | |
462 | value='text', |
|
462 | value='text', | |
463 | description='b', |
|
463 | description='b', | |
464 | ) |
|
464 | ) | |
@@ -467,16 +467,16 b' def test_default_description():' | |||||
467 | c = interactive(f, b='text') |
|
467 | c = interactive(f, b='text') | |
468 | w = c.children[0] |
|
468 | w = c.children[0] | |
469 | check_widget(w, |
|
469 | check_widget(w, | |
470 |
cls=widgets.Text |
|
470 | cls=widgets.Text, | |
471 | value='text', |
|
471 | value='text', | |
472 | description='b', |
|
472 | description='b', | |
473 | ) |
|
473 | ) | |
474 |
|
474 | |||
475 | def test_custom_description(): |
|
475 | def test_custom_description(): | |
476 |
c = interactive(f, b=widgets.Text |
|
476 | c = interactive(f, b=widgets.Text(value='text', description='foo')) | |
477 | w = c.children[0] |
|
477 | w = c.children[0] | |
478 | check_widget(w, |
|
478 | check_widget(w, | |
479 |
cls=widgets.Text |
|
479 | cls=widgets.Text, | |
480 | value='text', |
|
480 | value='text', | |
481 | description='foo', |
|
481 | description='foo', | |
482 | ) |
|
482 | ) |
General Comments 0
You need to be logged in to leave comments.
Login now