diff test_dataset.py @ 242:ef70a665aaaf

Hmm... that was committed by Fred I think, I got lost by Mercurial I think
author delallea@opale.iro.umontreal.ca
date Fri, 30 May 2008 10:19:16 -0400
parents 97f35d586727
children 0fb75fdd727d
line wrap: on
line diff
--- a/test_dataset.py	Fri May 30 10:14:46 2008 -0400
+++ b/test_dataset.py	Fri May 30 10:19:16 2008 -0400
@@ -194,38 +194,41 @@
     m=ds.minibatches(['x','y'],n_batches=1,minibatch_size=3,offset=4)
     assert isinstance(m,DataSet.MinibatchWrapAroundIterator)
     for x,y in m:
-        assert len(x)==3
-        assert len(y)==3
-        for id in range(3):
+        assert len(x)==m.minibatch_size
+        assert len(y)==m.minibatch_size
+        for id in range(m.minibatch_size):
             assert (numpy.append(x[id],y[id])==array[i+4]).all()
             i+=1
-    assert i==3
+    assert i==m.n_batches*m.minibatch_size
     del x,y,i,id,m
 
     i=0
     m=ds.minibatches(['x','y'],n_batches=2,minibatch_size=3,offset=4)
     assert isinstance(m,DataSet.MinibatchWrapAroundIterator)
     for x,y in m:
-        assert len(x)==3
-        assert len(y)==3
-        for id in range(3):
+        assert len(x)==m.minibatch_size
+        assert len(y)==m.minibatch_size
+        for id in range(m.minibatch_size):
             assert (numpy.append(x[id],y[id])==array[i+4]).all()
             i+=1
-    assert i==6
+    assert i==m.n_batches*m.minibatch_size
     del x,y,i,id,m
 
     i=0
     m=ds.minibatches(['x','y'],n_batches=20,minibatch_size=3,offset=4)
     assert isinstance(m,DataSet.MinibatchWrapAroundIterator)
     for x,y in m:
-        assert len(x)==3
-        assert len(y)==3
-        for id in range(3):
+        assert len(x)==m.minibatch_size
+        assert len(y)==m.minibatch_size
+        for id in range(m.minibatch_size):
             assert (numpy.append(x[id],y[id])==array[(i+4)%array.shape[0]]).all()
             i+=1
     assert i==m.n_batches*m.minibatch_size
     del x,y,i,id
 
+    #@todo: we can't do minibatch bigger then the size of the dataset???
+    assert have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array)+1,offset=0)
+    assert not have_raised2(ds.minibatches,['x','y'],n_batches=1,minibatch_size=len(array),offset=0)
 
 def test_ds_iterator(array,iterator1,iterator2,iterator3):
     l=len(iterator1)
@@ -494,10 +497,7 @@
     print "test_speed"
     import time
     a2 = numpy.random.rand(100000,400)
-    ds = ArrayDataSet(a2,{'x':slice(3),'y':3,'z':[0,2]})###???tuple not tested
-    ds = ArrayDataSet(a2,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested
     ds = ArrayDataSet(a2,{'all':slice(0,a2.shape[1],1)})
-    #assert ds==a? should this work?
     mat = numpy.random.rand(400,100)
     @print_timing
     def f_array1(a):