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

input_slider does not throw an error when value is function #979

Open
youngroklee-ml opened this issue Jan 8, 2024 · 0 comments
Open

input_slider does not throw an error when value is function #979

youngroklee-ml opened this issue Jan 8, 2024 · 0 comments

Comments

@youngroklee-ml
Copy link

youngroklee-ml commented Jan 8, 2024

When slider's value is set to be max function as below,

ui.input_slider("n", "N", min=0, max=100, value=max)

it does not throw an error but it create slider with initial value 0.

The followings also behave the same; they create slider with initial value 0 and do not throw errors.
ui.input_slider("n", "N", min=0, max=100, value="max")
ui.input_slider("n", "N", min=0, max=100, value=sum)
ui.input_slider("n", "N", min=0, max=100, value=min)

I think that more strict type checking for the value of input_slider() that throw error in above cases will help developers debug apps.

Below is a complete app to reproduce the example that I described above.

from shiny import Inputs, Outputs, Session, App, reactive, render, req, ui

app_ui = ui.page_fluid(
    ui.input_slider("n", "N", min=0, max=100, value=max),
    ui.output_text_verbatim("txt"),
)


def server(input: Inputs, output: Outputs, session: Session):
    @output
    @render.text
    def txt():
        return f"n*2 is {input.n() * 2}"


app = App(app_ui, server)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

1 participant