mirror of
https://github.com/cp2k/cp2k.git
synced 2026-07-21 14:35:15 -04:00
Updated tools/diff_cp2k.py (#3926)
- Split ENERGY line along white spaces and take the last item. - Some code comments (terminal colors).
This commit is contained in:
parent
44d3f296a0
commit
0974da54a8
1 changed files with 15 additions and 14 deletions
|
|
@ -87,7 +87,8 @@ def read_file(filename, field, special_keys, stats_keys):
|
|||
nameout[0] = line.split("=", 2)[1].strip()
|
||||
continue
|
||||
if "ENERGY| Total FORCE_EVAL ( QS ) energy" in line:
|
||||
nameout[1] = line.split(":", 2)[1].strip()
|
||||
split = line.split()
|
||||
nameout[1] = split[-1] # last item
|
||||
continue
|
||||
if "DBCSR STATISTICS" not in line and nstats == 0:
|
||||
continue
|
||||
|
|
@ -136,18 +137,18 @@ def print_value(ref, value, show_comp):
|
|||
comp = (value - ref) / ref * 100
|
||||
else:
|
||||
comp = float("Inf")
|
||||
color = "\033[0m"
|
||||
endc = "\033[0m"
|
||||
color = "\033[0m" # reset
|
||||
nocol = "\033[0m" # reset
|
||||
if comp > 0:
|
||||
color = "\033[92m"
|
||||
color = "\033[92m" # green
|
||||
elif comp < 0:
|
||||
color = "\033[94m"
|
||||
color = "\033[94m" # blue
|
||||
if abs(comp) > 100:
|
||||
color += "\033[1m"
|
||||
color += "\033[1m" # bold
|
||||
if show_comp:
|
||||
sys.stdout.write(color + "%10.3f" % value + "%5.0f" % comp + endc)
|
||||
sys.stdout.write(color + "%10.3f" % value + "%5.0f" % comp + nocol)
|
||||
else:
|
||||
sys.stdout.write(color + "%10.3f" % value + endc)
|
||||
sys.stdout.write(color + "%10.3f" % value + nocol)
|
||||
|
||||
|
||||
#################
|
||||
|
|
@ -272,17 +273,17 @@ def main():
|
|||
ref = 0
|
||||
if len(files[args.file_lists[args.base - 1]][1]) > 0:
|
||||
ref = float(files[args.file_lists[args.base - 1]][1])
|
||||
color = "\033[0m"
|
||||
endc = "\033[0m"
|
||||
color = "\033[0m" # reset
|
||||
nocol = "\033[0m" # reset
|
||||
for filename in args.file_lists:
|
||||
if len(files[filename][1]) > 0 and ref != 0:
|
||||
comp = (float(files[filename][1]) - ref) / ref
|
||||
if abs(comp) > 1e-14:
|
||||
color = "\033[91m"
|
||||
color = "\033[91m" # red
|
||||
else:
|
||||
color = "\033[0m"
|
||||
color = "\033[0m" # reset
|
||||
print(
|
||||
("{0} ==> {1} : {2} : " + color + "{3}" + endc).format(
|
||||
("{0} ==> {1} : {2} : " + color + "{3}" + nocol).format(
|
||||
files[filename][0],
|
||||
filename,
|
||||
files[filename][1],
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue