Mercurial > pylearn
diff test_dataset.py @ 207:c5a7105fa40b
trying to merge
author | Yoshua Bengio <bengioy@iro.umontreal.ca> |
---|---|
date | Fri, 16 May 2008 16:38:15 -0400 |
parents | b9950ae5e54b |
children | 3c96d23b36ac d7250ee86f72 |
line wrap: on
line diff
--- a/test_dataset.py Fri May 16 16:36:27 2008 -0400 +++ b/test_dataset.py Fri May 16 16:38:15 2008 -0400 @@ -394,6 +394,13 @@ assert len(ds('y').fields()) == 1 del field +def test_all(array,ds): + assert len(ds)==10 + + test_iterate_over_examples(array, ds) + test_getitem(array, ds) + test_ds_iterator(array,ds('x','y'),ds('y','z'),ds('x','y','z')) + test_fields_fct(ds) def test_ArrayDataSet(): #don't test stream @@ -406,13 +413,9 @@ a2 = numpy.random.rand(10,4) 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 - assert len(ds)==10 #assert ds==a? should this work? - test_iterate_over_examples(a2, ds) - test_getitem(a2, ds) - test_ds_iterator(a2,ds('x','y'),ds('y','z'),ds('x','y','z')) - test_fields_fct(ds) + test_all(a2,ds) del a2, ds @@ -442,18 +445,9 @@ ds1 = ArrayDataSet(a,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested ds2 = CachedDataSet(ds1) ds3 = CachedDataSet(ds1,cache_all_upon_construction=True) - assert len(ds2)==10 - assert len(ds3)==10 - test_iterate_over_examples(a, ds2) - test_getitem(a, ds2) - test_ds_iterator(a,ds2('x','y'),ds2('y','z'),ds2('x','y','z')) - test_fields_fct(ds2) - - test_iterate_over_examples(a, ds3) - test_getitem(a, ds3) - test_ds_iterator(a,ds3('x','y'),ds3('y','z'),ds3('x','y','z')) - test_fields_fct(ds3) + test_all(a,ds2) + test_all(a,ds3) del a,ds1,ds2,ds3 @@ -464,7 +458,18 @@ def test_ApplyFunctionDataSet(): print "test_ApplyFunctionDataSet" - raise NotImplementedError() + a = numpy.random.rand(10,4) + a2 = a+1 + ds1 = ArrayDataSet(a,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested + + ds2 = ApplyFunctionDataSet(ds1,lambda x,y,z: (x+1,y+1,z+1), ['x','y','z'],minibatch_mode=False) + ds3 = ApplyFunctionDataSet(ds1,lambda x,y,z: (numpy.array(x)+1,numpy.array(y)+1,numpy.array(z)+1), ['x','y','z'],minibatch_mode=True) + + test_all(a2,ds2) + test_all(a2,ds3) + + del a,ds1,ds2,ds3 + def test_FieldsSubsetDataSet(): print "test_FieldsSubsetDataSet" raise NotImplementedError() @@ -485,4 +490,5 @@ test_LookupList() test_ArrayDataSet() test_CachedDataSet() + test_ApplyFunctionDataSet() #test pmat.py