comparison _test_dataset.py @ 4:f7dcfb5f9d5b

Added test for dataset.
author bengioy@bengiomac.local
date Sun, 23 Mar 2008 22:14:10 -0400
parents
children d5738b79089a
comparison
equal deleted inserted replaced
3:378b68d5c4ad 4:f7dcfb5f9d5b
1 from dataset import *
2 from math import *
3 import unittest
4
5 def _sum_all(a):
6 s=a
7 while isinstance(s,numpy.ndarray):
8 s=sum(s)
9 return s
10
11 class T_arraydataset(unittest.TestCase):
12 def setUp(self):
13 numpy.random.seed(123456)
14
15 def test0(self):
16 a=ArrayDataSet(data=numpy.random.rand(8,3),fields={"x":slice(2),"y":slice(1,3)})
17 s=0
18 for example in a:
19 s+=_sum_all(example.x)
20 print s
21 self.failUnless(abs(s-11.4674133)<1e-6)
22
23 if __name__ == '__main__':
24 unittest.main()
25