changeset 165:2a12e7437c56

small refactoring
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Mon, 12 May 2008 17:51:28 -0400
parents 3518710e16ec
children ee11ed427ba8 c704a66706fe
files test_dataset.py
diffstat 1 files changed, 25 insertions(+), 33 deletions(-) [+]
line wrap: on
line diff
--- a/test_dataset.py	Mon May 12 17:43:53 2008 -0400
+++ b/test_dataset.py	Mon May 12 17:51:28 2008 -0400
@@ -33,6 +33,8 @@
         print "var=",var
     print "take a slice and look at field y",ds[1:6:2]["y"]
 
+    del a,ds,x,y,minibatch_iterator,minibatch,var
+
 def test_iterate_over_examples(array,ds):
 #not in doc!!!
     i=0
@@ -333,6 +335,23 @@
 #        del i,example
 #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#????
 
+def test_fields_fct(ds):
+    #@todo, fill correctly
+    assert len(ds.fields())==3
+    for field in ds.fields():
+        for field_value in field: # iterate over the values associated to that field for all the ds examples
+            pass
+    for field in ds('x','z').fields():
+        pass
+    for field in ds.fields('x','y'):
+        pass
+    for field_examples in ds.fields():
+        for example_value in field_examples:
+            pass
+
+    assert ds == ds.fields().examples()
+
+
 
 def test_ArrayDataSet():
     #don't test stream
@@ -353,23 +372,8 @@
 
 #     - for val1,val2,val3 in dataset(field1, field2,field3):
     test_ds_iterator(a2,ds('x','y'),ds('y','z'),ds('x','y','z'))
-
-
-    assert len(ds.fields())==3
-    for field in ds.fields():
-        for field_value in field: # iterate over the values associated to that field for all the ds examples
-            pass
-    for field in ds('x','z').fields():
-        pass
-    for field in ds.fields('x','y'):
-        pass
-    for field_examples in ds.fields():
-        for example_value in field_examples:
-            pass
-
-    assert ds == ds.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
+    test_fields_fct(ds)
+    del a2, ds
 
 def test_LookupList():
     #test only the example in the doc???
@@ -389,6 +393,8 @@
     assert example+example2==example3
     assert have_raised("var['x']+var['x']",x=example)
 
+    del example, example2, example3, x, y ,z
+
 def test_CachedDataSet():
     print "test_CacheDataSet"
     a2 = numpy.random.rand(10,4)
@@ -402,23 +408,9 @@
 
 #     - for val1,val2,val3 in dataset(field1, field2,field3):
     test_ds_iterator(a2,ds2('x','y'),ds2('y','z'),ds2('x','y','z'))
-
+    test_fields_fct(ds2)
 
-    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
+    del a2,ds1,ds2,ds3
 
 
 def test_DataSetFields():