# HG changeset patch # User Frederic Bastien # Date 1210621652 14400 # Node ID a5329e7192294189ceb5b6e64787160defd82ecb # Parent 933db7ece663496fde755eeb596fca907a7de76e added test for CachedDataSet diff -r 933db7ece663 -r a5329e719229 test_dataset.py --- a/test_dataset.py Mon May 12 15:35:18 2008 -0400 +++ b/test_dataset.py Mon May 12 15:47:32 2008 -0400 @@ -383,12 +383,41 @@ assert example+example2==example3 assert have_raised("var['x']+var['x']",x=example) +def test_CacheDataSet(): + print "test_CacheDataSet" + a2 = numpy.random.rand(10,4) + ds1 = ArrayDataSet(a2,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 + + 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'),ds(2'x','y','z')) + + + assert len(ds2.fields())==3 + for field in ds2.fields(): + for field_value in field: # iterate over the values associated to that field for all the ds examples + pass + for field in ds2('x','z').fields(): + pass + for field in ds2.fields('x','y'): + pass + for field_examples in ds2.fields(): + for example_value in field_examples: + pass + + assert ds2 == ds2.fields().examples() +# for ((x,y),a_v) in (ds('x','y'),a): #???don't work # haven't found a variant that work.# will not work +# assert numpy.append(x,y)==z + + def test_ApplyFunctionDataSet(): print "test_ApplyFunctionDataSet" raise NotImplementedError() -def test_CacheDataSet(): - print "test_CacheDataSet" - raise NotImplementedError() def test_FieldsSubsetDataSet(): print "test_FieldsSubsetDataSet" raise NotImplementedError() @@ -411,4 +440,5 @@ test1() test_LookupList() test_ArrayDataSet() +test_CacheDataSet() #test pmat.py