Update app.py
Browse files
app.py
CHANGED
|
@@ -1506,33 +1506,45 @@ def update_grid_rows(*args):
|
|
| 1506 |
if not show_na_filter:
|
| 1507 |
if active_preset == 'Writing':
|
| 1508 |
filtered_df.dropna(subset=['Writing βοΈ'], inplace=True)
|
|
|
|
|
|
|
| 1509 |
|
| 1510 |
# 6. Apply context-aware "NA Models" filter
|
| 1511 |
if show_na_filter:
|
| 1512 |
-
all_selections = set(uncensored_cols + intelligence_cols + writing_cols + politics_cols)
|
| 1513 |
if active_preset == 'Overview':
|
| 1514 |
-
|
| 1515 |
-
|
| 1516 |
-
|
| 1517 |
-
|
| 1518 |
-
|
| 1519 |
-
|
| 1520 |
-
|
| 1521 |
-
|
| 1522 |
-
|
| 1523 |
-
na_conditions.append(filtered_df['Writing βοΈ'].isna())
|
| 1524 |
-
if is_pred_reasoning_visible:
|
| 1525 |
-
na_conditions.append(filtered_df['Show Rec Score'] == -99999)
|
| 1526 |
-
if is_politics_visible:
|
| 1527 |
-
na_conditions.append(filtered_df['Political Lean π'].isna())
|
| 1528 |
-
|
| 1529 |
-
if na_conditions:
|
| 1530 |
-
final_na_mask = pd.Series(False, index=filtered_df.index)
|
| 1531 |
-
for condition in na_conditions:
|
| 1532 |
-
final_na_mask |= condition
|
| 1533 |
-
filtered_df = filtered_df[final_na_mask]
|
| 1534 |
else:
|
| 1535 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1536 |
|
| 1537 |
return filtered_df.to_dict('records')
|
| 1538 |
|
|
|
|
| 1506 |
if not show_na_filter:
|
| 1507 |
if active_preset == 'Writing':
|
| 1508 |
filtered_df.dropna(subset=['Writing βοΈ'], inplace=True)
|
| 1509 |
+
if active_preset == 'Politics':
|
| 1510 |
+
filtered_df = filtered_df[filtered_df['Political Lean π'] != -99999]
|
| 1511 |
|
| 1512 |
# 6. Apply context-aware "NA Models" filter
|
| 1513 |
if show_na_filter:
|
|
|
|
| 1514 |
if active_preset == 'Overview':
|
| 1515 |
+
# Special logic for Overview: show rows if EITHER Writing OR Politics is NA
|
| 1516 |
+
writing_na_mask = filtered_df['Writing βοΈ'].isna()
|
| 1517 |
+
politics_na_mask = filtered_df['Political Lean π'] == -99999
|
| 1518 |
+
filtered_df = filtered_df[writing_na_mask | politics_na_mask]
|
| 1519 |
+
|
| 1520 |
+
elif active_preset == 'Politics':
|
| 1521 |
+
# Special logic for Politics: ONLY show rows where Political Lean is NA
|
| 1522 |
+
filtered_df = filtered_df[filtered_df['Political Lean π'] == -99999]
|
| 1523 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1524 |
else:
|
| 1525 |
+
# Existing logic for all other presets (Uncensored, Intelligence, Writing)
|
| 1526 |
+
all_selections = set(uncensored_cols + intelligence_cols + writing_cols + politics_cols)
|
| 1527 |
+
|
| 1528 |
+
is_writing_visible = 'Writing βοΈ' in all_selections
|
| 1529 |
+
is_politics_visible = 'Political Lean π' in all_selections
|
| 1530 |
+
is_pred_reasoning_visible = 'world_model_group' in intelligence_cols
|
| 1531 |
+
|
| 1532 |
+
na_conditions = []
|
| 1533 |
+
if is_writing_visible:
|
| 1534 |
+
na_conditions.append(filtered_df['Writing βοΈ'].isna())
|
| 1535 |
+
if is_pred_reasoning_visible:
|
| 1536 |
+
na_conditions.append(filtered_df['Show Rec Score'] == -99999)
|
| 1537 |
+
if is_politics_visible:
|
| 1538 |
+
na_conditions.append(filtered_df['Political Lean π'] == -99999)
|
| 1539 |
+
|
| 1540 |
+
if na_conditions:
|
| 1541 |
+
final_na_mask = pd.Series(False, index=filtered_df.index)
|
| 1542 |
+
for condition in na_conditions:
|
| 1543 |
+
final_na_mask |= condition
|
| 1544 |
+
filtered_df = filtered_df[final_na_mask]
|
| 1545 |
+
else:
|
| 1546 |
+
# If no NA-able columns are selected, show nothing.
|
| 1547 |
+
filtered_df = filtered_df.iloc[0:0]
|
| 1548 |
|
| 1549 |
return filtered_df.to_dict('records')
|
| 1550 |
|