Spaces:
Sleeping
Sleeping
Timo
commited on
Commit
·
4e2cb37
1
Parent(s):
dca011f
Stale layout
Browse files- src/streamlit_app.py +10 -13
src/streamlit_app.py
CHANGED
|
@@ -228,12 +228,6 @@ with tabs[0]:
|
|
| 228 |
pack = st.session_state["pack"]
|
| 229 |
deck = st.session_state["deck"]
|
| 230 |
|
| 231 |
-
try:
|
| 232 |
-
pick, logits, scores = rank_cards(deck, pack)
|
| 233 |
-
if pick:
|
| 234 |
-
st.success(f"💡 Suggested pick: **{pick}**", icon="✨")
|
| 235 |
-
except Exception as e:
|
| 236 |
-
st.error(f"Error calculating card rankings: {e}")
|
| 237 |
|
| 238 |
options = list(model.cards[set_code.lower()].keys())
|
| 239 |
c1, c2 = st.columns(2)
|
|
@@ -257,7 +251,7 @@ with tabs[0]:
|
|
| 257 |
name_col, rm_col = st.columns([6, 3], gap="small")
|
| 258 |
name_col.write(card)
|
| 259 |
with rm_col:
|
| 260 |
-
if st.button("
|
| 261 |
remove_card("deck", card)
|
| 262 |
st.rerun()
|
| 263 |
else:
|
|
@@ -274,17 +268,22 @@ with tabs[0]:
|
|
| 274 |
on_change=_add_selected_to_pack, # <- auto-add
|
| 275 |
)
|
| 276 |
|
| 277 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 278 |
|
| 279 |
-
if st.session_state["pack"]:
|
| 280 |
-
# header row
|
| 281 |
st.button("🗑️ Clear pack", on_click=lambda: st.session_state.update(pack=[]), use_container_width=True)
|
| 282 |
h1, h2, h3 = st.columns([6, 2, 3])
|
| 283 |
h1.markdown("**Card**")
|
| 284 |
h2.markdown("**Score**")
|
| 285 |
h3.markdown("**Pick?**")
|
| 286 |
|
| 287 |
-
pack_list = st.session_state["pack"]
|
| 288 |
vals = [scores.get(c) if scores and c in scores else np.nan for c in pack_list]
|
| 289 |
logits = [logits.get(c) if logits and c in logits else np.nan for c in pack_list]
|
| 290 |
df_scores = pd.DataFrame({"Card": pack_list, "Score": vals, "Logits": logits})
|
|
@@ -314,8 +313,6 @@ with tabs[0]:
|
|
| 314 |
help="Add to deck & clear pack",
|
| 315 |
on_click=_pick_card, args=(card,),
|
| 316 |
)
|
| 317 |
-
else:
|
| 318 |
-
st.caption("Pack is empty.")
|
| 319 |
|
| 320 |
# --- Tab 2: Card rankings ----------------------------------------------------
|
| 321 |
|
|
|
|
| 228 |
pack = st.session_state["pack"]
|
| 229 |
deck = st.session_state["deck"]
|
| 230 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 231 |
|
| 232 |
options = list(model.cards[set_code.lower()].keys())
|
| 233 |
c1, c2 = st.columns(2)
|
|
|
|
| 251 |
name_col, rm_col = st.columns([6, 3], gap="small")
|
| 252 |
name_col.write(card)
|
| 253 |
with rm_col:
|
| 254 |
+
if st.button("❌", key=f"rm-deck-{i}", use_container_width=True):
|
| 255 |
remove_card("deck", card)
|
| 256 |
st.rerun()
|
| 257 |
else:
|
|
|
|
| 268 |
on_change=_add_selected_to_pack, # <- auto-add
|
| 269 |
)
|
| 270 |
|
| 271 |
+
pack_list = list(st.session_state.get("pack", []))
|
| 272 |
+
if not pack_list:
|
| 273 |
+
st.caption("Pack is empty.")
|
| 274 |
+
else:
|
| 275 |
+
|
| 276 |
+
try:
|
| 277 |
+
pick, logits, scores = rank_cards(deck, pack)
|
| 278 |
+
except Exception as e:
|
| 279 |
+
st.error(f"Error calculating card rankings: {e}")
|
| 280 |
|
|
|
|
|
|
|
| 281 |
st.button("🗑️ Clear pack", on_click=lambda: st.session_state.update(pack=[]), use_container_width=True)
|
| 282 |
h1, h2, h3 = st.columns([6, 2, 3])
|
| 283 |
h1.markdown("**Card**")
|
| 284 |
h2.markdown("**Score**")
|
| 285 |
h3.markdown("**Pick?**")
|
| 286 |
|
|
|
|
| 287 |
vals = [scores.get(c) if scores and c in scores else np.nan for c in pack_list]
|
| 288 |
logits = [logits.get(c) if logits and c in logits else np.nan for c in pack_list]
|
| 289 |
df_scores = pd.DataFrame({"Card": pack_list, "Score": vals, "Logits": logits})
|
|
|
|
| 313 |
help="Add to deck & clear pack",
|
| 314 |
on_click=_pick_card, args=(card,),
|
| 315 |
)
|
|
|
|
|
|
|
| 316 |
|
| 317 |
# --- Tab 2: Card rankings ----------------------------------------------------
|
| 318 |
|