Dealing with the RangeError on `st.slider`?

Hi guys!

I’ve got a RangeError with st.slider, where I get my min and max values dynamically from a dataframe,

The issue is raised as the min value (100) is equal to the max value (100)

Here’s a video of the error in the app:

2020-06-25_10-44-01

Here’s the related error code:

RangeError: min (100) is equal/bigger than max (100)
at Object.t.checkBoundaries (http://192.168.1.106:8502/static/js/26.e7807516.chunk.js:1:5385)
at http://192.168.1.106:8502/static/js/26.e7807516.chunk.js:1:15260
at Array.forEach (<anonymous>)
at t.componentDidMount (http://192.168.1.106:8502/static/js/26.e7807516.chunk.js:1:15231)
at Ks (http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:2005475)
at t.unstable_runWithPriority (http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:2026579)
at pi (http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:1951856)
at Zs (http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:2001475)
at Fs (http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:1990112)
at http://192.168.1.106:8502/static/js/10.bd8c2f6b.chunk.js:1:1952127

Heres’ my Python code:

maxValueToken_set = dfRatio['token_set_ratio'].max()
    minValueToken_set = dfRatio['token_set_ratio'].min()
    Token_set_slider = st.slider('token set ratio values', minValueToken_set, maxValueToken_set, value = maxValueToken_set, step = 1.00)

After trying several error handling methods, nothing has worked so far - I’ll keep digging but any idea?

Thanks,
Charly

I think this is probably one of those things you’d need to catch in the codebase; from the slider perspective, there’s no way to show zero width (100 to 100), so I think it’s right to throw an error.

Is this a scenario where you can reasonably expect to have columns with constant values?

1 Like

Thanks for the prompt response Randy!

Yes, one can reasonably expect to have columns with constant values with this web app.

I’ll try to find a workaround and will keep you posted on the progress here! :slight_smile:

Charly

1 Like

Since you’re already calculating min and max, could you do something like:


if minValueToken_set < maxValueToken_set:
   st.slider(...)
else:
   st.write("This column is a constant of value `minValueToken`")
2 Likes