comparison test_dataset.py @ 66:dde1fb1b63ba

fixed test and removed print
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Fri, 02 May 2008 11:24:17 -0400
parents d48eba49a2f4
children b4159cbdc06b 4b0859606d05
comparison
equal deleted inserted replaced
65:d48eba49a2f4 66:dde1fb1b63ba
21 print "minibatch=",minibatch 21 print "minibatch=",minibatch
22 for var in minibatch: 22 for var in minibatch:
23 print "var=",var 23 print "var=",var
24 print "take a slice and look at field y",ds[1:6:2]["y"] 24 print "take a slice and look at field y",ds[1:6:2]["y"]
25 25
26 def test2():
27 a = numpy.random.rand(10,4)
28 print a
29 ds = ArrayDataSet(a,{'x':slice(3),'y':3,'z':[0,2]})
30 for x,z in ds[:3]('x','z'):
31 assert ds[i]['z'].all()==a[i][0:3:2].all()
32
33 def test_ArrayDataSet(): 26 def test_ArrayDataSet():
34 #don't test stream 27 #don't test stream
35 #tested only with float value 28 #tested only with float value
36 a = numpy.random.rand(10,4) 29 a = numpy.random.rand(10,4)
37 print a 30 print a
93 86
94 87
95 #test missing value 88 #test missing value
96 89
97 assert len(ds[:3])==3 90 assert len(ds[:3])==3
91 i=0
98 for x,z in ds[:3]('x','z'): 92 for x,z in ds[:3]('x','z'):
99 assert ds[i]['z'].all()==a[i][0:3:2].all() 93 assert ds[i]['z'].all()==a[i][0:3:2].all()
100 94 i+=1
101 #ds[i1:i2:s]# returns a ds with the examples i1,i1+s,...i2-s. 95 #ds[i1:i2:s]# returns a ds with the examples i1,i1+s,...i2-s.
102 96
103 #ds[i]# returns an Example. 97 #ds[i]# returns an Example.
104 98
105 #ds[[i1,i2,...in]]# returns a ds with examples i1,i2,...in. 99 #ds[[i1,i2,...in]]# returns a ds with examples i1,i2,...in.
114 # - 'fieldtypes': a list of types (one per field) 108 # - 'fieldtypes': a list of types (one per field)
115 #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3]) 109 #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])
116 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3]) 110 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])
117 111
118 112
119 #test2()
120
121 test_ArrayDataSet() 113 test_ArrayDataSet()
122 114