-
Notifications
You must be signed in to change notification settings - Fork 27
/
Copy pathtest_regress.py
executable file
·83 lines (68 loc) · 1.95 KB
/
test_regress.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#!/usr/bin/env python
# compare output of fract4d with saved 'known good' files
# complain about anything different
# this requires the Python Imaging Library to run.
import operator
import os
from functools import reduce
from PIL import Image, ImageChops, ImageStat
good_files = [
# look ok
"abyssal.fct",
"antialias_bug.fct",
"bailout_breaker.fct",
#"barnsley_t2_odd.fct",
"barnsley_worm.fct",
"cathedral.fct",
"chaos_engine.fct",
"compass_rose.fct",
"crest.fct",
"cubicspiral.fct",
"towers.fct",
"valley_of_obvious_errors.fct",
"shattered.fct",
]
bad_files = [
# not equivalent
"caduceus.fct",
"caduceus_fixed.fct",
"contrail.fct",
"daisychain.fct",
]
def render(outfile, fctfile):
cmd = f"./gnofract4d --nogui --threads 4 -i 64 -j 48 -s {outfile} -q {fctfile}"
#print cmd
ret = os.system(cmd)
if ret != 0:
raise Exception("error generating image")
def compare(fctfile):
outbase = os.path.basename(fctfile) + ".png"
outfile = "testdata/new_output/" + outbase
render(outfile, fctfile)
new_image = Image.open(outfile)
old_image = Image.open("testdata/saved_output/" + outbase)
diff = ImageChops.difference(new_image, old_image)
diff_file = "testdata/diffs/" + outbase
diff.save(diff_file)
stats = ImageStat.Stat(diff)
print("%f\t%d\t%f" % \
(total(stats.mean), total(stats.median), total(stats.rms)))
def total(l):
return reduce(operator.__add__, l)
def check_file(f):
try:
print("%s\t" % f, end=' ')
compare(f)
except Exception as err:
print("Error %s" % err)
if __name__ == '__main__':
import sys
print("file\tmean\tmedian\trms")
if len(sys.argv) > 1:
for f in sys.argv[1:]:
check_file(f)
else:
for f in ["testdata/" + x for x in good_files]:
check_file(f)
for f in ["testdata/" + x for x in bad_files]:
check_file(f)