Spaces:
Sleeping
Sleeping
Commit History
-
fix(plot): correct export return value count (5β6)
Alex W.6f3ba20 -
```β
Alex W.ValueError: A function (gen_single_export) didn't return enough output values (needed: 6, returned: 5). Output components: [textbox, image, file, file, file, file] ``` Reproduced on HF Space after clicking π¨οΈ Export PNG / PDF / SVG. The `outputs` list in both export button wirings has 6 components: ```python outputs=[single_status, single_preview, # 1: status text dl_s_png, dl_s_pdf, dl_s_svg, dl_s_zip] # 2: image preview # 3-6: file downloads ``` But all return paths in `gen_single_export` and `gen_compare_export` returned only 5 values β `single_preview` (the PNG image component) was in the outputs list but had no corresponding return value. All return paths in both functions updated from 5 β 6 values. The PNG path is reused for both the image preview and the PNG download: ```python return status, png, pdf, svg, zip_p return status, png, png, pdf, svg, zip_p ``` Early-exit error paths also fixed (None count: β¦06b76e9 -
Three UX issues reported on Tab 5 Interactive view:β
Alex W.1. **Layout unusable** β 4Γ3 grid compressed into a fixed Plotly canvas made each subplot too small to read. 2. **Width overflow** β matplotlib's physical canvas size (18Γ20 in) was inherited by `mpl_to_plotly`, causing the figure to exceed the page width. 3. **Slow response** β `mpl_to_plotly` rendered matplotlib first (server-side), then converted the entire figure to Plotly JSON. Double rendering + large polygon count from IQR bands made interaction sluggish. Root cause: all three issues trace back to a single architectural mistake β using `mpl_to_plotly` as a bridge instead of two independent rendering paths. --- **Throw away the bridge. Two completely independent engines.** ``` Interactive β core/plotter_plotly.py (native Plotly) Export β core/plotter.py (matplotlib, unchanged) ``` No conversion between them. Each optimized for its own purpose. --- Native Plotly figure generation. Zero matplotlib dependency. **Layout: 12Γ1 vertical stack** Eacβ¦7ecfc20 -
Add `core/plotter.py` and `ui/tab_plot.py` to generate Nature/PRL-standardβ
Alex W.figures for Wang's Five Laws directly from the SQLite database. Update `app.py` to mount the new Tab 5. --- Pure computation layer. No UI dependency, no DB dependency. Takes a `pd.DataFrame` (from `db/reader.py`) and returns `matplotlib.Figure`. - `plot_single_model()` β 4Γ3 grid (12 subplots), single model - `plot_compare_models()` β 4Γ3 grid, Model A (solid) vs Model B (dashed) - `save_figure()` β exports PNG (300 dpi) + PDF (vector) + SVG (vector) - `fig_to_plotly()` β converts matplotlib Figure to Plotly for interactive preview - `fig_to_png_bytes()` β in-memory PNG bytes for Gradio Image component Gradio Tab 5 interface. Calls `core/plotter.py` and `db/reader.py` only. - Single-model mode: select model β generate β preview β download - Two-model comparison mode: select A & B β generate β preview β download - Controls: modality filter, layer range, band toggle, delta toggle - Download: PNG / PDF / SVG / ZIP (all formats bundled) --- - Added `from ui.tab_plot import build_tabβ¦9d65593