Skip to content
Snippets Groups Projects
Commit e52620fa authored by DIANE's avatar DIANE
Browse files

common

parent ec738d53
No related branches found
No related tags found
No related merge requests found
......@@ -26,4 +26,4 @@ from utils.visualize import *
from utils.miscellaneous import ObjectHash
from utils.samsel import Samplers
from report import report
from utils.data_handling import fmt
\ No newline at end of file
from utils.data_handling import fmt, st_var
\ No newline at end of file
......@@ -75,7 +75,7 @@ def fmt(x):
return x if x else "<Select>"
def st_var(variable, initialize=True, update=False):
def st_var(variable, initialize=True, update=False, type= 'increment'):
"""
Manages a variable in the Streamlit session state, allowing it to be initialized, updated,
and retained across interactions.
......@@ -112,13 +112,19 @@ def st_var(variable, initialize=True, update=False):
# Initialize the variable if needed
if initialize:
if variable not in st.session_state:
st.session_state[variable] = 0
if type =='increment':
st.session_state[variable] = 0
elif type =='boolean':
st.session_state[variable] = False
else:
pass
# Update the variable if needed
if update:
st.session_state[variable] += 1
if type =='increment':
st.session_state[variable] += 1
elif type =='boolean':
st.session_state[variable] = not st.session_state[variable]
def list_files(mypath, import_type):
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment