Mercurial > pylearn
changeset 170:bc72a0fa6d01
Automated merge with ssh://p-omega1@lgcm.iro.umontreal.ca/tlearn
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Tue, 13 May 2008 13:09:59 -0400 |
parents | 4803cb76e26b (current diff) 051e07807554 (diff) |
children | 895b4b60f5e8 |
files | |
diffstat | 1 files changed, 54 insertions(+), 16 deletions(-) [+] |
line wrap: on
line diff
--- a/test_dataset.py Mon May 12 18:51:42 2008 -0400 +++ b/test_dataset.py Tue May 13 13:09:59 2008 -0400 @@ -306,14 +306,17 @@ for example in ds['x']: assert (example==array[i][:3]).all() i+=1 + assert i==len(ds) i=0 for example in ds['y']: assert (example==array[i][3]).all() i+=1 + assert i==len(ds) i=0 for example in ds['z']: assert (example==array[i,0:3:2]).all() i+=1 + assert i==len(ds) del ds2,i #ds.<property># returns the value of a property associated with @@ -338,20 +341,52 @@ def test_fields_fct(ds): #@todo, fill correctly assert len(ds.fields())==3 + i=0 + v=0 for field in ds.fields(): for field_value in field: # iterate over the values associated to that field for all the ds examples - pass + v+=1 + i+=1 + assert i==3 + assert v==3*10 + del i,v + + i=0 + v=0 for field in ds('x','z').fields(): - pass + i+=1 + for val in field: + v+=1 + assert i==2 + assert v==2*10 + del i,v + + i=0 + v=0 for field in ds.fields('x','y'): - pass + i+=1 + for val in field: + v+=1 + assert i==2 + assert v==2*10 + del i,v + + i=0 + v=0 for field_examples in ds.fields(): for example_value in field_examples: - pass - + v+=1 + i+=1 + assert i==3 + assert v==3*10 + del i,v + assert ds == ds.fields().examples() + assert len(ds('x','y').fields()) == 2 + assert len(ds('x','z').fields()) == 2 + assert len(ds('y').fields()) == 1 - + del field def test_ArrayDataSet(): #don't test stream @@ -369,10 +404,9 @@ test_iterate_over_examples(a2, ds) test_getitem(a2, ds) - -# - for val1,val2,val3 in dataset(field1, field2,field3): test_ds_iterator(a2,ds('x','y'),ds('y','z'),ds('x','y','z')) test_fields_fct(ds) + del a2, ds def test_LookupList(): @@ -397,20 +431,24 @@ def test_CachedDataSet(): print "test_CacheDataSet" - a2 = numpy.random.rand(10,4) - ds1 = ArrayDataSet(a2,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested + a = numpy.random.rand(10,4) + 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(a2, ds2) - test_getitem(a2, ds2) - -# - for val1,val2,val3 in dataset(field1, field2,field3): - test_ds_iterator(a2,ds2('x','y'),ds2('y','z'),ds2('x','y','z')) + 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) - del a2,ds1,ds2,ds3 + 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) + + del a,ds1,ds2,ds3 def test_DataSetFields():