Rimjhim Mittal commited on
Commit ·
55ebabc
1
Parent(s): 1ae2624
fixing parameter input alignment
Browse files
app.py
CHANGED
|
@@ -102,7 +102,6 @@ def show_json_model(mdf_model):
|
|
| 102 |
st.subheader("JSON Model")
|
| 103 |
st.json(mdf_model.to_json())
|
| 104 |
|
| 105 |
-
# st.cache_data()
|
| 106 |
def view_tabs(mdf_model, param_inputs, stateful): # view
|
| 107 |
tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Model"])
|
| 108 |
with tab1:
|
|
@@ -112,7 +111,6 @@ def view_tabs(mdf_model, param_inputs, stateful): # view
|
|
| 112 |
show_simulation_results(st.session_state.simulation_results, stateful)
|
| 113 |
else:
|
| 114 |
st.write("No simulation results available.")
|
| 115 |
-
|
| 116 |
with tab2:
|
| 117 |
show_mdf_graph(mdf_model) # view
|
| 118 |
with tab3:
|
|
@@ -121,8 +119,6 @@ def view_tabs(mdf_model, param_inputs, stateful): # view
|
|
| 121 |
def display_and_edit_array(array, key):
|
| 122 |
if isinstance(array, list):
|
| 123 |
array = np.array(array)
|
| 124 |
-
|
| 125 |
-
# st.write(array)
|
| 126 |
rows, cols = array.shape if array.ndim > 1 else (1, len(array))
|
| 127 |
if rows*cols > 10:
|
| 128 |
st.write(array)
|
|
@@ -188,8 +184,13 @@ def parameter_form_to_update_model_and_view(mdf_model):
|
|
| 188 |
|
| 189 |
# Create four columns for each node
|
| 190 |
col1, col2, col3, col4 = st.columns(4)
|
| 191 |
-
|
| 192 |
for i, param in enumerate(node.parameters):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 193 |
if isinstance(param.value, str) or param.value is None:
|
| 194 |
continue
|
| 195 |
key = f"{param.id}_{node_index}_{i}"
|
|
@@ -235,7 +236,7 @@ def parameter_form_to_update_model_and_view(mdf_model):
|
|
| 235 |
valid_inputs = False
|
| 236 |
|
| 237 |
run_button = st.form_submit_button("Run Simulation")
|
| 238 |
-
|
| 239 |
if run_button:
|
| 240 |
if valid_inputs:
|
| 241 |
for node in nodes:
|
|
@@ -247,7 +248,7 @@ def parameter_form_to_update_model_and_view(mdf_model):
|
|
| 247 |
else:
|
| 248 |
st.error("Please correct the invalid inputs before running the simulation.")
|
| 249 |
|
| 250 |
-
|
| 251 |
|
| 252 |
def upload_file_and_load_to_model():
|
| 253 |
|
|
|
|
| 102 |
st.subheader("JSON Model")
|
| 103 |
st.json(mdf_model.to_json())
|
| 104 |
|
|
|
|
| 105 |
def view_tabs(mdf_model, param_inputs, stateful): # view
|
| 106 |
tab1, tab2, tab3 = st.tabs(["Simulation Results", "MDF Graph", "Json Model"])
|
| 107 |
with tab1:
|
|
|
|
| 111 |
show_simulation_results(st.session_state.simulation_results, stateful)
|
| 112 |
else:
|
| 113 |
st.write("No simulation results available.")
|
|
|
|
| 114 |
with tab2:
|
| 115 |
show_mdf_graph(mdf_model) # view
|
| 116 |
with tab3:
|
|
|
|
| 119 |
def display_and_edit_array(array, key):
|
| 120 |
if isinstance(array, list):
|
| 121 |
array = np.array(array)
|
|
|
|
|
|
|
| 122 |
rows, cols = array.shape if array.ndim > 1 else (1, len(array))
|
| 123 |
if rows*cols > 10:
|
| 124 |
st.write(array)
|
|
|
|
| 184 |
|
| 185 |
# Create four columns for each node
|
| 186 |
col1, col2, col3, col4 = st.columns(4)
|
| 187 |
+
parameter_list = []
|
| 188 |
for i, param in enumerate(node.parameters):
|
| 189 |
+
if isinstance(param.value, str) or param.value is None:
|
| 190 |
+
continue
|
| 191 |
+
else:
|
| 192 |
+
parameter_list.append(param)
|
| 193 |
+
for i, param in enumerate(parameter_list):
|
| 194 |
if isinstance(param.value, str) or param.value is None:
|
| 195 |
continue
|
| 196 |
key = f"{param.id}_{node_index}_{i}"
|
|
|
|
| 236 |
valid_inputs = False
|
| 237 |
|
| 238 |
run_button = st.form_submit_button("Run Simulation")
|
| 239 |
+
view_tabs(mdf_model, param_inputs, stateful_nodes)
|
| 240 |
if run_button:
|
| 241 |
if valid_inputs:
|
| 242 |
for node in nodes:
|
|
|
|
| 248 |
else:
|
| 249 |
st.error("Please correct the invalid inputs before running the simulation.")
|
| 250 |
|
| 251 |
+
|
| 252 |
|
| 253 |
def upload_file_and_load_to_model():
|
| 254 |
|