changeset 202:b9950ae5e54b

Added test for ApplyFunctionDataset
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Thu, 15 May 2008 13:10:21 -0400
parents c9c966cab763
children 80731832c62b
files test_dataset.py
diffstat 1 files changed, 13 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/test_dataset.py	Thu May 15 13:09:26 2008 -0400
+++ b/test_dataset.py	Thu May 15 13:10:21 2008 -0400
@@ -458,7 +458,18 @@
 
 def test_ApplyFunctionDataSet():
     print "test_ApplyFunctionDataSet"
-    raise NotImplementedError()
+    a = numpy.random.rand(10,4)
+    a2 = a+1
+    ds1 = ArrayDataSet(a,LookupList(['x','y','z'],[slice(3),3,[0,2]]))###???tuple not tested
+
+    ds2 = ApplyFunctionDataSet(ds1,lambda x,y,z: (x+1,y+1,z+1), ['x','y','z'],minibatch_mode=False)
+    ds3 = ApplyFunctionDataSet(ds1,lambda x,y,z: (numpy.array(x)+1,numpy.array(y)+1,numpy.array(z)+1), ['x','y','z'],minibatch_mode=True)
+
+    test_all(a2,ds2)
+    test_all(a2,ds3)
+
+    del a,ds1,ds2,ds3
+
 def test_FieldsSubsetDataSet():
     print "test_FieldsSubsetDataSet"
     raise NotImplementedError()
@@ -479,4 +490,5 @@
     test_LookupList()
     test_ArrayDataSet()
     test_CachedDataSet()
+    test_ApplyFunctionDataSet()
 #test pmat.py