ViewVC Help
View File | Revision Log | Show Annotations | Download File | Root Listing
root/radiance/ray/test/py_tests/test_histo.py
Revision: 1.4
Committed: Mon Mar 28 17:48:43 2016 UTC (9 years, 2 months ago) by schorsch
Content type: text/x-python
Branch: MAIN
CVS Tags: HEAD
Changes since 1.3: +0 -0 lines
State: FILE REMOVED
Log Message:
Refactoring of test suite, use independently of SCons and with Py2.7 or 3.x.

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