ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_histo.py
Revision: 1.2
Committed: Sun Dec 14 21:04:07 2003 UTC (20 years, 4 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: rad3R7P2, rad4R2P2, rad4R2P1, rad3R7P1, rad4R2, rad4R1, rad4R0, rad3R6, rad3R6P1, rad3R8, rad3R9, rad5R0
Changes since 1.1: +69 -7 lines
Log Message:
Added tests for -c and -p options. Changed intervals to avoid rounding instabilities.

File Contents

# User Rev Content
1 schorsch 1.1
2     import os
3     import string
4     import unittest
5    
6     from unit_tools import support
7     from unit_tools import lcompare
8    
9     class HistoTestCase(unittest.TestCase):
10     def setUp(self):
11     self.oldpath = os.environ['PATH']
12     os.environ['PATH'] = os.path.abspath(support.BINDIR)
13    
14     def tearDown(self):
15     os.environ['PATH'] = self.oldpath
16    
17     def test_histo(self):
18 schorsch 1.2 cmd = 'histo -0.5 8.5 9 < "%s"' % support.datafile('histo.dat')
19 schorsch 1.1 raw = os.popen(cmd).read()
20     result = map(string.split,string.split(raw,'\n'))
21     expect = [
22 schorsch 1.2 [0, 720, 240, 432, 1080, 270],
23     [1, 720, 240, 432, 1080, 270],
24     [2, 720, 240, 432, 0, 270],
25     [3, 0, 240, 432, 0, 270],
26     [4, 0, 240, 432, 0, 270],
27     [5, 0, 240, 0, 0, 270],
28     [6, 0, 240, 0, 0, 270],
29     [7, 0, 240, 0, 0, 270],
30     [8, 0, 240, 0, 0, 0],
31     ]
32     try: lcompare.llcompare(result, expect, ignore_empty=1)
33     except lcompare.error, e:
34     self.fail('%s [%s]' % (str(e),cmd))
35    
36     def test_histo_c(self):
37     cmd = 'histo -c -0.5 8.5 9 < "%s"' % support.datafile('histo.dat')
38     raw = os.popen(cmd).read()
39     result = map(string.split,string.split(raw,'\n'))
40     expect = [
41     [-0.5, 0, 0, 0, 0, 0],
42     [0.5, 720, 240, 432, 1080, 270],
43     [1.5, 1440, 480, 864, 2160, 540],
44     [2.5, 2160, 720, 1296, 2160, 810],
45     [3.5, 2160, 960, 1728, 2160, 1080],
46     [4.5, 2160, 1200, 2160, 2160, 1350],
47     [5.5, 2160, 1440, 2160, 2160, 1620],
48     [6.5, 2160, 1680, 2160, 2160, 1890],
49     [7.5, 2160, 1920, 2160, 2160, 2160],
50     [8.5, 2160, 2160, 2160, 2160, 2160],
51     ]
52     try: lcompare.llcompare(result, expect, ignore_empty=1)
53     except lcompare.error, e:
54     self.fail('%s [%s]' % (str(e),cmd))
55    
56     def test_histo_p(self):
57     cmd = 'histo -p -0.5 8.5 9 < "%s"' % support.datafile('histo.dat')
58     raw = os.popen(cmd).read()
59     result = map(string.split,string.split(raw,'\n'))
60     expect = [
61     [0, 33.333333, 11.111111, 20.0, 50.0, 12.5],
62     [1, 33.333333, 11.111111, 20.0, 50.0, 12.5],
63     [2, 33.333333, 11.111111, 20.0, 0.0, 12.5],
64     [3, 0.0, 11.111111, 20.0, 0.0, 12.5],
65     [4, 0.0, 11.111111, 20.0, 0.0, 12.5],
66     [5, 0.0, 11.111111, 0.0, 0.0, 12.5],
67     [6, 0.0, 11.111111, 0.0, 0.0, 12.5],
68     [7, 0.0, 11.111111, 0.0, 0.0, 12.5],
69     [8, 0.0, 11.111111, 0.0, 0.0, 0.0],
70     ]
71     try: lcompare.llcompare(result, expect, ignore_empty=1)
72     except lcompare.error, e:
73     self.fail('%s [%s]' % (str(e),cmd))
74    
75     def test_histo_pc(self):
76     cmd = 'histo -p -c -0.5 8.5 9 < "%s"' % support.datafile('histo.dat')
77     raw = os.popen(cmd).read()
78     result = map(string.split,string.split(raw,'\n'))
79     expect = [
80     [-0.5, 0.0, 0.0, 0.0, 0.0, 0.0],
81     [0.5, 33.333333, 11.111111, 20.0, 50.0, 12.5],
82     [1.5, 66.666667, 22.222222, 40.0, 100.0, 25.0],
83     [2.5, 100.0, 33.333333, 60.0, 100.0, 37.5],
84     [3.5, 100.0, 44.444444, 80.0, 100.0, 50.0],
85     [4.5, 100.0, 55.555556, 100.0, 100.0, 62.5],
86     [5.5, 100.0, 66.666667, 100.0, 100.0, 75.0],
87     [6.5, 100.0, 77.777778, 100.0, 100.0, 87.5],
88     [7.5, 100.0, 88.888889, 100.0, 100.0, 100.0],
89     [8.5, 100.0, 100.0, 100.0, 100.0, 100.0],
90 schorsch 1.1 ]
91     try: lcompare.llcompare(result, expect, ignore_empty=1)
92     except lcompare.error, e:
93     self.fail('%s [%s]' % (str(e),cmd))
94    
95     def main():
96     support.run_case(HistoTestCase)
97    
98     if __name__ == '__main__':
99     main()
100    
101     # vi: set ts=4 sw=4 :