Skip to content

Commit

Permalink
add extremely simple regression testing script
Browse files Browse the repository at this point in the history
  • Loading branch information
zeddie888 committed Nov 13, 2023
1 parent 35e2f84 commit ac37fef
Show file tree
Hide file tree
Showing 2 changed files with 62 additions and 1 deletion.
2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
*.out.*
*.lisp
*.org
*.py
# *.py
*.json
/.gdb_history

Expand Down
61 changes: 61 additions & 0 deletions reg.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,61 @@
# Script to check performance on images in given folder and prevent regression testing

This comment has been minimized.

Copy link
@markasoftware

markasoftware Nov 14, 2023

Member

regressions are prevented by regression testing

regression testing is prevented by regression testing testing

so this is a regression testing test

cf wikipedia

In all seriousness stuff like this is fine for testing for oresat delivery but the long-term way to do this kind of testing would be to add a new comparator to the core that's able to read expected attitudes from a file.

This comment has been minimized.

Copy link
@zeddie888

zeddie888 Nov 14, 2023

Author Collaborator

lol
and agreed, in the end I won't include this file in the MR, this is just to help log some data

# 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()

0 comments on commit ac37fef

Please sign in to comment.