From ac37fef1157aa9a962ae8c95b7237a9627300230 Mon Sep 17 00:00:00 2001 From: Edward Zhang Date: Mon, 13 Nov 2023 10:54:54 -0800 Subject: [PATCH] add extremely simple regression testing script --- .gitignore | 2 +- reg.py | 61 ++++++++++++++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 62 insertions(+), 1 deletion(-) create mode 100644 reg.py diff --git a/.gitignore b/.gitignore index 24f784a7..44e21caf 100644 --- a/.gitignore +++ b/.gitignore @@ -11,7 +11,7 @@ *.out.* *.lisp *.org -*.py +# *.py *.json /.gdb_history diff --git a/reg.py b/reg.py new file mode 100644 index 00000000..6c3418cf --- /dev/null +++ b/reg.py @@ -0,0 +1,61 @@ +# Script to check performance on images in given folder and prevent regression testing +# Go over all images in some folder and check performance, log it to stdout (for now) +# TODO: figure out some storage plan + +# CLI: +# test directory name, output log name +# (optional) attitude estimator + +import subprocess +import argparse +import os +import datetime + +parser = argparse.ArgumentParser() +parser.add_argument("test_dir", type=str) +parser.add_argument("log", type=str, default="log.txt") +parser.add_argument("-att_estimator", type=str, nargs="?", default="dqm") +args = parser.parse_args() + +print(f"Testing images in {args.test_dir}") +print(f"attitude estimator: {args.att_estimator}") +print(f"Logging outputs to {args.log}") + + +def get_diff(expected, actual): + """Get element-wise angle difference between expected and actual (what we got)""" + return [expected[i] - actual[i] for i in range(len(actual))] + + +output_log = open(args.log, "a+") # append to end of log, don't overwrite +for img_name in os.listdir(args.test_dir): + cmd = ( + f"./lost pipeline \ + --png {img_name} \ + --fov 17 \ + --centroid-algo cog \ + --centroid-filter-brightest 6 \ + --star-id-algo tetra \ + --database tetra-algo-12.dat \ + --false-stars 0 \ + --attitude-algo {args.att_estimator} \ + --print-attitude attitude.txt \ + --plot-output annotated-res.png", + ) + subprocess.call(cmd, shell=True) + # log attitude.txt + # Log: + # which image was tested + # Output from attitude.txt + dt = datetime.datetime.now().isoformat() + output_log.write("----------------------------\n") + output_log.write(f"{img_name}-{dt}-{args.att_estimator}\n") + output_log.write("----------------------------\n") + with open("attitude.txt") as att_log: + targets = ["attitude_ra", "attitude_de", "attitude_roll"] + for line in att_log: + line = line.split(" ") + if line[0] in targets: + output_log.write(line[1]) + +output_log.close()