Skip to content
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 11 commits into from
Dec 20, 2022

Conversation

freddyaboulton
Copy link
Collaborator

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:

  • I have performed a self-review of my own code
  • I have added a short summary of my change to the CHANGELOG.md
  • My code follows the style guidelines of this project
  • I have commented my code in hard-to-understand areas
  • I have made corresponding changes to the documentation
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes

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.

@freddyaboulton freddyaboulton force-pushed the 2562-checkbox-group-invalid-value branch from 606418f to 51d344f Compare December 20, 2022 21:50
@github-actions
Copy link
Contributor

All the demos for this PR have been deployed at https://huggingface.co/spaces/gradio-pr-deploys/pr-2866-all-demos

freddyaboulton and others added 6 commits December 20, 2022 16:53
* Pass samples_per_page to examples

* Add to changelog

Co-authored-by: Abubakar Abid <abubakar@huggingface.co>
@@ -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
Copy link
Member

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

@abidlabs
Copy link
Member

LGTM thanks for the fix @freddyaboulton!

I would also update the typehint in line 902 and docstring in line 915

@freddyaboulton
Copy link
Collaborator Author

Thank you @abidlabs !

@freddyaboulton freddyaboulton merged commit 943b4ed into main Dec 20, 2022
@freddyaboulton freddyaboulton deleted the 2562-checkbox-group-invalid-value branch December 20, 2022 23:02
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Setting value of CheckboxGroup to an integer causes an infinite loading loop.
2 participants