Skip to content

Commit

Permalink
Merge pull request #80 from AllenNeuralDynamics/han_fix_plotly_selection
Browse files Browse the repository at this point in the history
Han fix plotly selection
  • Loading branch information
hanhou authored Aug 11, 2024
2 parents 2629cc9 + 2439049 commit 81a46c7
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 10 deletions.
7 changes: 4 additions & 3 deletions code/util/plot_autotrain_manager.py
Original file line number Diff line number Diff line change
Expand Up @@ -201,9 +201,10 @@ def plot_manager_all_progress(manager: 'AutoTrainManager',

# Limit x range to recent days if x is "date"
if x_axis == 'date' and recent_days is not None:
xrange_min = datetime.now() - pd.Timedelta(days=recent_days)
xrange_max = datetime.now()
fig.update_xaxes(range=[xrange_min, xrange_max])
# xrange_max = pd.Timestamp.today() # For unknown reasons, using this line will break both plotly_events and new st.plotly_chart callback...
xrange_max = pd.to_datetime(df_manager.session_date).max() + pd.Timedelta(days=1)
xrange_min = xrange_max - pd.Timedelta(days=recent_days)
fig.update_layout(xaxis_range=[xrange_min, xrange_max])

# Highight the selected subject
for n, subject_id in enumerate(subject_ids):
Expand Down
12 changes: 6 additions & 6 deletions code/util/streamlit.py
Original file line number Diff line number Diff line change
Expand Up @@ -697,7 +697,7 @@ def add_auto_train_manager():
st_prefix=cols[0],
label="X axis",
options=options,
default=options.index(st.session_state["auto_training_history_x_axis"]),
default="date",
key="auto_training_history_x_axis",
)

Expand All @@ -706,7 +706,7 @@ def add_auto_train_manager():
st_prefix=cols[1],
label="Sort by",
options=options,
default=options.index(st.session_state["auto_training_history_sort_by"]),
default="first_date",
key="auto_training_history_sort_by",
)

Expand All @@ -715,7 +715,7 @@ def add_auto_train_manager():
st_prefix=cols[2],
label="Sort order",
options=options,
default=options.index(st.session_state["auto_training_history_sort_order"]),
default="descending",
key="auto_training_history_sort_order",
)

Expand Down Expand Up @@ -769,7 +769,7 @@ def add_auto_train_manager():
override_height=fig_auto_train.layout.height * 1.1,
override_width=fig_auto_train.layout.width,
click_event=True,
select_event=False,
select_event=True,
)
with cols[1]:
st.markdown('#### 👀 Quick preview')
Expand Down Expand Up @@ -801,8 +801,8 @@ def add_auto_train_manager():
'decision', 'next_stage_suggested'
]]

with st.expander('Automatic training manager', expanded=True):
st.dataframe(df_training_manager, height=3000)
# with st.expander('Automatic training manager', expanded=True):
# st.dataframe(df_training_manager, height=3000)

@st.cache_data(ttl=3600*24)
def _plot_population_x_y(df, x_name='session', y_name='foraging_eff', group_by='h2o',
Expand Down
2 changes: 1 addition & 1 deletion code/util/url_query_helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,7 @@
'auto_training_curriculum_name': 'Uncoupled Baiting',
'auto_training_curriculum_version': '1.0',
'auto_training_curriculum_schema_version': '1.0',
'auto_training_history_recent_weeks': 4,
'auto_training_history_recent_weeks': 8,
}

def checkbox_wrapper_for_url_query(st_prefix, label, key, default, **kwargs):
Expand Down

0 comments on commit 81a46c7

Please sign in to comment.