53 lines
1.2 KiB
Python
Executable File
53 lines
1.2 KiB
Python
Executable File
#!/usr/bin/env python
|
|
|
|
USAGE = """fx-csv: Creates a LaTeX table from results.
|
|
|
|
Example:
|
|
|
|
fx-latex knn_k ./main kfold/0/knn/params/k kfold/results/p_correct >knn_k.tex
|
|
fx-latex --preview knn_k ./main kfold/0/knn/params/k kfold/results/p_correct
|
|
|
|
The second command assumes you have latex, dvipdf, and xpdf installed, and will
|
|
pop open a preview window for the table.
|
|
|
|
See help for fx-csv for information on how to form queries.
|
|
|
|
"""
|
|
|
|
import pm
|
|
import util
|
|
import datastore
|
|
import fxsys
|
|
import fx # use FASTexec argument parsing
|
|
|
|
import sys
|
|
import os
|
|
|
|
if len(fx.extra_args) < 3:
|
|
print USAGE
|
|
sys.exit(1)
|
|
|
|
label = fx.extra_args[0]
|
|
exename = os.path.abspath(fx.extra_args[1])
|
|
paths = fx.extra_args[2:]
|
|
preview = fx.param_bool("preview")
|
|
|
|
experiment = fxsys.SimpleExperiment(os.path.abspath("."), exename, label)
|
|
|
|
if preview:
|
|
outfile = open("fx-latex.tex", "w")
|
|
else:
|
|
outfile = sys.stdout
|
|
|
|
relative_paths = ["*/" + fxsys.OUTPUT_FNAME + ":/" + path.lstrip("/") for path in paths]
|
|
datastore.select_fields_to_table_file(
|
|
outfile, experiment.path, relative_paths,
|
|
util.write_latex_table_file)
|
|
|
|
if preview:
|
|
outfile.close()
|
|
util.shell("latex fx-latex.tex")
|
|
util.shell("dvipdf fx-latex.dvi")
|
|
util.shell("xpdf fx-latex.pdf")
|
|
|