Skip to content

Commit

Permalink
add basic ANSI color code for test output
Browse files Browse the repository at this point in the history
  • Loading branch information
JamesJieranShen committed Dec 9, 2024
1 parent 576c877 commit 192954d
Showing 1 changed file with 3 additions and 3 deletions.
6 changes: 3 additions & 3 deletions python/rattest/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -126,7 +126,7 @@ def run(self, regen_mc=False, regen_plots=False, html=None):
Run a full RAT test, including simulation and the ROOT macro.
Includes writing results to the HTML file, if option is specified.
'''
print('=' * 5 + ' Run Test: {} '.format(self.name) + '=' * 5)
print("\033[1;35m" + '=' * 5 + ' Run Test: {} '.format(self.name) + '=' * 5 + "\033[0m")
self._do_run(regen_mc=regen_mc, regen_plots=regen_plots)

if html:
Expand Down Expand Up @@ -248,7 +248,7 @@ def compare_hists(self, master_fname, current_fname, html=None):
prob = m_obj.KolmogorovTest(c_obj)
if m_obj.GetEntries() == 0 and c_obj.GetEntries() == 0:
prob = 1
print("Comparing {}: {}".format(objname, c_obj.GetTitle()))
print("\033[1;34mComparing {}: {}\033[0m".format(objname, c_obj.GetTitle()))

#Require a perfect match if desired, else test against critical_probability
if self.KS_threshold == 1.0:
Expand All @@ -264,7 +264,7 @@ def compare_hists(self, master_fname, current_fname, html=None):
success = False
overall_success = False

success_message = "SUCCESS" if (success and overall_success) else "FAILURE"
success_message = "\033[1;32mSUCCESS\033[0m" if (success and overall_success) else "\033[1;31mFAILURE\033[0m"
print(" {}: KS prob = {}".format(success_message, prob))

plotfile = os.path.join(self.testdir, objname + '.png')
Expand Down

0 comments on commit 192954d

Please sign in to comment.