changeset 289:3af204aa71e5

implemented test for FieldsSubsetDataSet. if executed, can take a --debug option to be used in a debugger
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Fri, 06 Jun 2008 16:15:43 -0400
parents 2d08f46d17d8
children f7924e13e426
files _test_dataset.py
diffstat 1 files changed, 18 insertions(+), 3 deletions(-) [+]
line wrap: on
line diff
--- a/_test_dataset.py	Fri Jun 06 14:08:28 2008 -0400
+++ b/_test_dataset.py	Fri Jun 06 16:15:43 2008 -0400
@@ -1,7 +1,7 @@
 #!/bin/env python
 from dataset import *
 from math import *
-import numpy,unittest
+import numpy, unittest, sys
 from misc import *
 
 def have_raised(to_eval, **var):
@@ -426,7 +426,13 @@
         del a,ds1,ds2,ds3
 
     def test_FieldsSubsetDataSet(self):
-        raise NotImplementedError()
+        a = numpy.random.rand(10,4)
+        ds = ArrayDataSet(a,LookupList(['x','y','z','w'],[slice(3),3,[0,2],0]))
+        ds = FieldsSubsetDataSet(ds,['x','y','z'])
+
+        test_all(a,ds)
+
+        del a, ds
     def test_MinibatchDataSet(self):
         raise NotImplementedError()
     def test_HStackedDataSet(self):
@@ -438,5 +444,14 @@
 
 
 if __name__=='__main__':
-    unittest.main()
+    if len(sys.argv)==2:
+        if sys.argv[1]=="--debug":
+            module = __import__("_test_dataset")
+            tests = unittest.TestLoader().loadTestsFromModule(module)
+            tests.debug()
+        print "bad argument: only --debug is accepted"
+    elif len(sys.argv)==1:
+        unittest.main()
+    else:
+        print "bad argument: only --debug is accepted"