changeset 169:051e07807554

added test for CachedDataSet(ds,cache_all_upon_construction=True)
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 13 May 2008 13:05:45 -0400
parents c704a66706fe
children bc72a0fa6d01
files test_dataset.py
diffstat 1 files changed, 13 insertions(+), 10 deletions(-) [+]
line wrap: on
line diff
--- a/test_dataset.py	Tue May 13 13:00:54 2008 -0400
+++ b/test_dataset.py	Tue May 13 13:05:45 2008 -0400
@@ -404,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():
@@ -432,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():