From 034487a3ef9112cf99bf4687cc58abd3e61ad4ce Mon Sep 17 00:00:00 2001 From: hh_itx_win10 Date: Sun, 14 Apr 2024 22:46:18 -0700 Subject: [PATCH 1/2] fix: collapsing slider range when there is only one session filtered --- code/util/streamlit.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/code/util/streamlit.py b/code/util/streamlit.py index 01d4afb..778f31e 100644 --- a/code/util/streamlit.py +++ b/code/util/streamlit.py @@ -288,9 +288,9 @@ def filter_dataframe(df: pd.DataFrame, else: x = df[column] - _min = float(x.min()) - _max = float(x.max()) - step = (_max - _min) / 100 + _min = float(x.min() - 0.05 * abs(x.min())) # Avoid collapsing the range + _max = float(x.max() + 0.05 * abs(x.max())) + step = (_max - _min) / min(100, len(np.unique(x)) + 1) # Avoid too many steps c_hist = st.container() # Histogram @@ -306,10 +306,12 @@ def filter_dataframe(df: pd.DataFrame, zip(st.session_state[f'filter_{column}'], (_min, _max))] else: default_value = (_min, _max) - + + default_value = list(default_value) + default_value[0] = max(_min, default_value[0]) + default_value[1] = min(_max, default_value[1]) st.session_state[f'filter_{column}'] = default_value - user_num_input = st.slider( f"Values for {column}", label_visibility='collapsed', From cf698c075c962f0e8aa1dc26f329a459e59ff126 Mon Sep 17 00:00:00 2001 From: hh_itx_win10 Date: Sun, 14 Apr 2024 22:46:38 -0700 Subject: [PATCH 2/2] ci: bump version --- code/Home.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/code/Home.py b/code/Home.py index 91babf7..cce7c18 100644 --- a/code/Home.py +++ b/code/Home.py @@ -12,7 +12,7 @@ """ -__ver__ = 'v2.2.1' +__ver__ = 'v2.2.2' import pandas as pd import streamlit as st