From d038eec253146b4e4ed0592837641f2ae49429e5 Mon Sep 17 00:00:00 2001 From: Birte Kristina Friesel Date: Tue, 25 Mar 2025 16:09:17 +0100 Subject: add pseudo-dataref export for ACM TAPS etc --- lib/cli.py | 23 +++++++++++++++++++++++ 1 file changed, 23 insertions(+) (limited to 'lib') diff --git a/lib/cli.py b/lib/cli.py index 75f6890..419ddcd 100644 --- a/lib/cli.py +++ b/lib/cli.py @@ -331,6 +331,23 @@ def model_quality_table( print(buf) +def export_pseudo_dref(dref_file, dref, precision=None): + with open(dref_file, "w") as f: + for k, v in sorted(os.environ.items(), key=lambda kv: kv[0]): + if k.startswith("DFATOOL_"): + print(f"% {k}='{v}'", file=f) + for arg in sys.argv: + print(f"% {arg}", file=f) + for k, v in sorted(dref.items()): + k = k.replace("/", "I").replace("-", "").replace(" ", "") + if type(v) is tuple: + v = v[0] + if type(v) in (float, np.float64) and precision is not None: + print("\\def\\" + k + "{" + f"{v:.{precision}f}" + "}") + else: + print("\\def\\" + k + "{" + str(v) + "}") + + def export_dataref(dref_file, dref, precision=None): with open(dref_file, "w") as f: for k, v in sorted(os.environ.items(), key=lambda kv: kv[0]): @@ -492,6 +509,12 @@ def add_standard_arguments(parser): type=str, help="Export tree-based model to {PREFIX}{name}-{attribute}.dot", ) + parser.add_argument( + "--export-pseudo-dref", + metavar="FILE", + type=str, + help="Export model and model quality to LaTeX def file (sort of like dataref)", + ) parser.add_argument( "--export-dref", metavar="FILE", -- cgit v1.2.3