Skip to content

Commit

Permalink
Merge pull request #66 from AllenNeuralDynamics/han_fix_32
Browse files Browse the repository at this point in the history
Fix: collapsing slider range when only one sessions is filtered
  • Loading branch information
hanhou authored Apr 15, 2024
2 parents f1704e0 + cf698c0 commit e1ccfc7
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 6 deletions.
2 changes: 1 addition & 1 deletion code/Home.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
"""

__ver__ = 'v2.2.1'
__ver__ = 'v2.2.2'

import pandas as pd
import streamlit as st
Expand Down
12 changes: 7 additions & 5 deletions code/util/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand All @@ -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',
Expand Down

0 comments on commit e1ccfc7

Please sign in to comment.