diff options
-rwxr-xr-x | bin/analyze-archive.py | 4 | ||||
-rwxr-xr-x | bin/analyze-kconfig.py | 4 | ||||
-rw-r--r-- | lib/cli.py | 15 |
3 files changed, 19 insertions, 4 deletions
diff --git a/bin/analyze-archive.py b/bin/analyze-archive.py index a111492..1f5aba7 100755 --- a/bin/analyze-archive.py +++ b/bin/analyze-archive.py @@ -1036,7 +1036,9 @@ if __name__ == "__main__": ) dref["constructor duration"] = (constructor_duration, r"\second") dref["regression duration"] = (fit_duration, r"\second") - dfatool.cli.export_dataref(args.export_dref, dref) + dfatool.cli.export_dataref( + args.export_dref, dref, precision=args.dref_precision + ) if args.export_webconf: if not pta: diff --git a/bin/analyze-kconfig.py b/bin/analyze-kconfig.py index 4aea5c6..8b11084 100755 --- a/bin/analyze-kconfig.py +++ b/bin/analyze-kconfig.py @@ -586,7 +586,9 @@ def main(): ) dref["constructor duration"] = (constructor_duration, r"\second") dref["regression duration"] = (fit_duration, r"\second") - dfatool.cli.export_dataref(args.export_dref, dref) + dfatool.cli.export_dataref( + args.export_dref, dref, precision=args.dref_precision + ) if args.config: kconf = kconfiglib.Kconfig(args.kconfig_path) @@ -6,6 +6,7 @@ from dfatool.functions import ( StaticFunction, FOLFunction, ) +import numpy as np def print_static(model, static_model, name, attribute): @@ -148,7 +149,7 @@ def model_quality_table(header, result_lists, info_list): print(buf) -def export_dataref(dref_file, dref): +def export_dataref(dref_file, dref, precision=None): with open(dref_file, "w") as f: for k, v in sorted(dref.items()): if type(v) is not tuple: @@ -157,7 +158,11 @@ def export_dataref(dref_file, dref): prefix = r"\drefset{" else: prefix = r"\drefset" + f"[unit={v[1]}]" + "{" - print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f) + if type(v[0]) in (float, np.float64) and precision is not None: + print(f"Limiting precision to {precision}") + print(f"{prefix}/{k}" + "}{" + f"{v[0]:.{precision}f}" + "}", file=f) + else: + print(f"{prefix}/{k}" + "}{" + str(v[0]) + "}", file=f) def export_dot(model, dot_prefix): @@ -213,6 +218,12 @@ def add_standard_arguments(parser): help="Export raw (parameter-independent) observations in tikz-pgf-compatible format to {PREFIX}{name}-{attribute}.txt", ) parser.add_argument( + "--dref-precision", + metavar="NDIG", + type=int, + help="Limit precision of dataref export to NDIG decimals", + ) + parser.add_argument( "--export-xv", metavar="FILE", type=str, |