-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Wrap value in list for CheckBoxGroup. #2866
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
606418f
to
51d344f
Compare
All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2866-all-demos |
* Pass samples_per_page to examples * Add to changelog Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
abidlabs
reviewed
Dec 20, 2022
gradio/components.py
Outdated
@@ -991,15 +991,19 @@ def preprocess(self, x: List[str]) -> List[str] | List[int]: | |||
+ ". Please choose from: 'value', 'index'." | |||
) | |||
|
|||
def postprocess(self, y: List[str] | None) -> List[str]: | |||
def postprocess(self, y: List[str] | str | None) -> List[str]: | |||
""" | |||
Any postprocessing needed to be performed on function output. | |||
Parameters: | |||
y: List of selected choices |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Suggested change
y: List of selected choices | |
y: List of selected choices. If a single choice is selected, it can be passed in as a string |
LGTM thanks for the fix @freddyaboulton! I would also update the typehint in line 902 and docstring in line 915 |
abidlabs
approved these changes
Dec 20, 2022
…-app/gradio into 2562-checkbox-group-invalid-value
Thank you @abidlabs ! |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Description
Fixes #2562 and add test
We have two options 1) wrap the value in a list if it's not a list already or 2) raise an error.
I went with option 1 as that's probably what the user meant.
Checklist:
A note about the CHANGELOG
Hello 👋 and thank you for contributing to Gradio!
All pull requests must update the change log located in CHANGELOG.md, unless the pull request is labeled with the "no-changelog-update" label.
Please add a brief summary of the change to the Upcoming Release > Full Changelog section of the CHANGELOG.md file and include
a link to the PR (formatted in markdown) and a link to your github profile (if you like). For example, "* Added a cool new feature by
[@myusername](link-to-your-github-profile)
in[PR 11111](https://github.com/gradio-app/gradio/pull/11111)
".If you would like to elaborate on your change further, feel free to include a longer explanation in the other sections.
If you would like an image/gif/video showcasing your feature, it may be best to edit the CHANGELOG file using the
GitHub web UI since that lets you upload files directly via drag-and-drop.