diff _test_dataset.py @ 22:b6b36f65664f

Created virtual sub-classes of DataSet: {Finite{Length,Width},Sliceable}DataSet, removed .field ability from LookupList (because of setattr problems), removed fieldNames() from DataSet (but is in FiniteWidthDataSet, where it makes sense), and added hasFields() instead. Fixed problems in asarray, and tested previous functionality in _test_dataset.py, but not yet new functionality.
author bengioy@esprit.iro.umontreal.ca
date Mon, 07 Apr 2008 20:44:37 -0400
parents fdf0abc490f7
children 672fe4b23032
line wrap: on
line diff
--- a/_test_dataset.py	Mon Apr 07 19:32:52 2008 -0400
+++ b/_test_dataset.py	Mon Apr 07 20:44:37 2008 -0400
@@ -50,10 +50,13 @@
 
     def test_asarray(self):
         arr = numpy.random.rand(3,4)
+        a=ArrayDataSet(data=arr,fields={"x":slice(2),"y":slice(2,4)})
+        a_arr = numpy.asarray(a)
+        self.failUnless(a_arr.shape[1] == 2 + 2)
+        self.failUnless(numpy.sum(numpy.square(a_arr-a.data))==0)
         a=ArrayDataSet(data=arr,fields={"x":slice(2),"y":slice(1,4)})
         a_arr = numpy.asarray(a)
         self.failUnless(a_arr.shape[1] == 2 + 3)
-        self.failUnless(a_arr == arr)
 
     def test_minibatch_wraparound_even(self):
         arr = numpy.random.rand(10,4)