feat: Add SVG and PDF vector export for statistical plots#124
Conversation
|
Hi, @dippatel1994 I hope you're doing well. |
dippatel1994
left a comment
There was a problem hiding this comment.
Good feature design. Three things to fix:
-
Windows tests fail — path injection bug —
VECTOR_PATH_{fmt} = "{vec_path}"uses f-string with unescaped backslashes. On Windows,C:\Users\...has\Uwhich is an invalid unicode escape → SyntaxError. Fix withrepr(path)orpath.replace('\\', '/'). Same pre-existing bug onOUTPUT_PATH— fix both while you're here. -
Lint fails — 3 ruff errors: two E501 (line too long) in
visualizer.pyandcli.py, one F401 (unusedimport pytest) in test file. -
VectorFormattype alias defined but never used —paperbanana/core/config.pyaddsVectorFormat = Literal["svg", "pdf"]but it's never imported or referenced. Either use it to type-annotatevector_formatsor remove it.
|
Thanks for your response, @dippatel1994 |
dippatel1994
left a comment
There was a problem hiding this comment.
Windows path bug and VectorFormat removal are fixed, nice work. Tests all pass now including Windows.
Lint still fails though. It's a formatting issue, not a code error. Run ruff format paperbanana/agents/visualizer.py tests/test_agents/test_visualizer.py and push.
Okay, thanks for your active response. |
|
Just done! |
dippatel1994
left a comment
There was a problem hiding this comment.
All issues fixed. Windows path bug resolved, lint clean, VectorFormat removed. CI fully green. LGTM.
PR Description
This pull request adds vector format export (SVG and PDF) for statistical plots, enabling publication-ready figures for academic venues such as NeurIPS, ICML, and ICLR with no new dependencies.
Related Issue: Closes #97
Key Changes
New CLI Flag (
paperbanana generate):--vector / --no-vector— exports SVG and PDF alongside the raster output for statistical plotsFalse, leaving MCP server and batch runner unaffectedVisualizerAgent(paperbanana/agents/visualizer.py):_execute_plot_code()— strips any VLM-injectedVECTOR_PATH_*assignments, injects authoritativeVECTOR_PATH_SVG/VECTOR_PATH_PDFvariables into the script header, and appendsplt.savefig()calls for each requested format after user coderun()/_generate_plot()— acceptvector_formatsparameter; results stored inself._last_vector_pathsafter each execution{}at the start of everyrun()call to prevent bleed between iterationsSettings (
paperbanana/core/config.py):vector_export: bool = False— new field onSettingsVectorFormat = Literal["svg", "pdf"]— type alias for valid vector formatsoutput.vector_exportsupported via_flatten_yamlPipeline (
paperbanana/core/pipeline.py):vector_formatsfromsettings.vector_exportin bothgenerate()andcontinue_run()vector_output_pathsdict tometadata.jsonwhen vector files are producedUsage