changeset 168:c704a66706fe

more test
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Tue, 13 May 2008 13:00:54 -0400
parents 2a12e7437c56
children 051e07807554
files test_dataset.py
diffstat 1 files changed, 41 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/test_dataset.py	Mon May 12 17:51:28 2008 -0400
+++ b/test_dataset.py	Tue May 13 13:00:54 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