diff test_dataset.py @ 239:77b362a23f8e

more general test
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Thu, 29 May 2008 10:41:35 -0400
parents 6aff510792dd
children 97f35d586727
line wrap: on
line diff
--- a/test_dataset.py	Thu May 29 10:30:59 2008 -0400
+++ b/test_dataset.py	Thu May 29 10:41:35 2008 -0400
@@ -194,33 +194,33 @@
     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