mirror of
https://github.com/gradio-app/gradio.git
synced 2025-02-23 11:39:17 +08:00
Fix .update()
for gr.Radio()
and gr.CheckboxGroup()
(#5254)
* fix dynamic -> interactive * fix checks * add changeset * add changeset * fix changeset * fix linting issues * Fix update choices * add test * fix' * revert * revert * Delete curly-hands-carry.md * add changeset * add changeset --------- Co-authored-by: pngwn <hello@pngwn.io> Co-authored-by: gradio-pr-bot <gradio-pr-bot@users.noreply.github.com>
This commit is contained in:
parent
a773eaf750
commit
c39f06e16b
5
.changeset/lemon-memes-clean.md
Normal file
5
.changeset/lemon-memes-clean.md
Normal file
@ -0,0 +1,5 @@
|
||||
---
|
||||
"gradio": patch
|
||||
---
|
||||
|
||||
fix:Fix `.update()` for `gr.Radio()` and `gr.CheckboxGroup()`
|
@ -133,6 +133,11 @@ class CheckboxGroup(
|
||||
interactive: bool | None = None,
|
||||
visible: bool | None = None,
|
||||
):
|
||||
choices = (
|
||||
None
|
||||
if choices is None
|
||||
else [c if isinstance(c, tuple) else (str(c), c) for c in choices]
|
||||
)
|
||||
return {
|
||||
"choices": choices,
|
||||
"label": label,
|
||||
|
@ -135,6 +135,11 @@ class Radio(
|
||||
interactive: bool | None = None,
|
||||
visible: bool | None = None,
|
||||
):
|
||||
choices = (
|
||||
None
|
||||
if choices is None
|
||||
else [c if isinstance(c, tuple) else (str(c), c) for c in choices]
|
||||
)
|
||||
return {
|
||||
"choices": choices,
|
||||
"label": label,
|
||||
|
@ -581,6 +581,16 @@ class TestRadio:
|
||||
scores = (await iface.interpret(["b"]))[0]["interpretation"]
|
||||
assert scores == [-2.0, None, 2.0]
|
||||
|
||||
def test_update(self):
|
||||
update = gr.Radio.update(
|
||||
choices=[("zeroth", ""), "first", "second"], label="ordinal"
|
||||
)
|
||||
assert update["choices"] == [
|
||||
("zeroth", ""),
|
||||
("first", "first"),
|
||||
("second", "second"),
|
||||
]
|
||||
|
||||
|
||||
class TestDropdown:
|
||||
def test_component_functions(self):
|
||||
|
Loading…
Reference in New Issue
Block a user