Update app.py
Browse files
app.py
CHANGED
|
@@ -251,32 +251,32 @@ def convert_to_title_case(text: str) -> str:
|
|
| 251 |
return title_case_text
|
| 252 |
|
| 253 |
|
| 254 |
-
def
|
| 255 |
csv_path = path + "/" + rl_env + ".csv"
|
| 256 |
data = pd.read_csv(csv_path)
|
| 257 |
|
| 258 |
if "Pattern" in data.columns:
|
| 259 |
key = "Pattern"
|
| 260 |
-
|
| 261 |
-
elif "
|
| 262 |
-
key = "
|
| 263 |
-
|
| 264 |
else:
|
| 265 |
key = None
|
| 266 |
-
|
| 267 |
|
| 268 |
-
return key,
|
| 269 |
|
| 270 |
def filter_data(rl_env, task_id, selected_values, path):
|
| 271 |
"""
|
| 272 |
-
Filters the data based on the selected
|
| 273 |
"""
|
| 274 |
data = get_data(rl_env, task_id, path)
|
| 275 |
|
| 276 |
# If there are selected values, filter the DataFrame
|
| 277 |
if selected_values:
|
| 278 |
-
filter_column = "Pattern" if "Pattern" in data.columns else "
|
| 279 |
-
if filter_column == "
|
| 280 |
selected_values = [np.int64(sv) for sv in selected_values]
|
| 281 |
data = data[data[filter_column].isin(selected_values)]
|
| 282 |
|
|
@@ -320,14 +320,14 @@ with block:
|
|
| 320 |
for env_index in range(0, len(hivex_envs)):
|
| 321 |
hivex_env = hivex_envs[env_index]
|
| 322 |
with gr.Tab(f"{hivex_env['title']}") as env_tabs:
|
| 323 |
-
dp_key,
|
| 324 |
hivex_env["hivex_env"], path_
|
| 325 |
)
|
| 326 |
|
| 327 |
-
# Check if dp_key is defined and
|
| 328 |
-
if dp_key is not None and len(
|
| 329 |
selected_checkboxes = gr.CheckboxGroup(
|
| 330 |
-
[str(dp_id) for dp_id in
|
| 331 |
)
|
| 332 |
|
| 333 |
for task_id in range(0, hivex_env["task_count"]):
|
|
|
|
| 251 |
return title_case_text
|
| 252 |
|
| 253 |
|
| 254 |
+
def get_elevation_pattern_ids_and_key(rl_env, path):
|
| 255 |
csv_path = path + "/" + rl_env + ".csv"
|
| 256 |
data = pd.read_csv(csv_path)
|
| 257 |
|
| 258 |
if "Pattern" in data.columns:
|
| 259 |
key = "Pattern"
|
| 260 |
+
elevation_pattern_ids = sorted(data[key].unique())
|
| 261 |
+
elif "Terrain Elevation Levels" in data.columns:
|
| 262 |
+
key = "Terrain Elevation Levels"
|
| 263 |
+
elevation_pattern_ids = sorted(data[key].unique())
|
| 264 |
else:
|
| 265 |
key = None
|
| 266 |
+
elevation_pattern_ids = []
|
| 267 |
|
| 268 |
+
return key, elevation_pattern_ids
|
| 269 |
|
| 270 |
def filter_data(rl_env, task_id, selected_values, path):
|
| 271 |
"""
|
| 272 |
+
Filters the data based on the selected elevation/pattern values.
|
| 273 |
"""
|
| 274 |
data = get_data(rl_env, task_id, path)
|
| 275 |
|
| 276 |
# If there are selected values, filter the DataFrame
|
| 277 |
if selected_values:
|
| 278 |
+
filter_column = "Pattern" if "Pattern" in data.columns else "Terrain Elevation Levels"
|
| 279 |
+
if filter_column == "Terrain Elevation Levels":
|
| 280 |
selected_values = [np.int64(sv) for sv in selected_values]
|
| 281 |
data = data[data[filter_column].isin(selected_values)]
|
| 282 |
|
|
|
|
| 320 |
for env_index in range(0, len(hivex_envs)):
|
| 321 |
hivex_env = hivex_envs[env_index]
|
| 322 |
with gr.Tab(f"{hivex_env['title']}") as env_tabs:
|
| 323 |
+
dp_key, elevation_pattern_ids = get_elevation_pattern_ids_and_key(
|
| 324 |
hivex_env["hivex_env"], path_
|
| 325 |
)
|
| 326 |
|
| 327 |
+
# Check if dp_key is defined and elevation_pattern_ids is not empty
|
| 328 |
+
if dp_key is not None and len(elevation_pattern_ids) > 0:
|
| 329 |
selected_checkboxes = gr.CheckboxGroup(
|
| 330 |
+
[str(dp_id) for dp_id in elevation_pattern_ids], label=dp_key
|
| 331 |
)
|
| 332 |
|
| 333 |
for task_id in range(0, hivex_env["task_count"]):
|