diff dataset.py @ 61:a8b70a9117ad

bugfix: in MinibatchDataSet renamed the class variable fields to _fields as parent class have a function called field. bugfix: next_example is a class variable...
author Frederic Bastien <bastienf@iro.umontreal.ca>
date Fri, 02 May 2008 09:55:38 -0400
parents 9165d86855ab
children 23bf2c9eb7b3
line wrap: on
line diff
--- a/dataset.py	Thu May 01 16:26:34 2008 -0400
+++ b/dataset.py	Fri May 02 09:55:38 2008 -0400
@@ -588,7 +588,7 @@
         and a values_hstack(fieldnames,fieldvalues) functions behaving with the same
         semantics as the DataSet methods of the same name (but without the self argument).
         """
-        self.fields=fields_lookuplist
+        self._fields=fields_lookuplist
         assert len(fields_lookuplist)>0
         self.length=len(fields_lookuplist[0])
         for field in fields_lookuplist[1:]:
@@ -602,18 +602,18 @@
     def __getitem__(self,i):
         if type(i) in (int,slice,list):
             return DataSetFields(MinibatchDataSet(
-                Example(self.fields.keys(),[field[i] for field in self.fields])),self.fields)
+                Example(self._fields.keys(),[field[i] for field in self._fields])),self._fields)
         if self.hasFields(i):
-            return self.fields[i]
+            return self._fields[i]
         assert i in self.__dict__ # else it means we are trying to access a non-existing property
         return self.__dict__[i]
 
     def fieldNames(self):
-        return self.fields.keys()
+        return self._fields.keys()
 
     def hasFields(self,*fieldnames):
         for fieldname in fieldnames:
-            if fieldname not in self.fields.keys():
+            if fieldname not in self._fields.keys():
                 return False
         return True
 
@@ -628,11 +628,11 @@
             def __iter__(self):
                 return self
             def next(self):
-                upper = next_example+minibatch_size
+                upper = self.next_example+minibatch_size
                 assert upper<=self.ds.length
-                minibatch = Example(self.ds.fields.keys(),
-                                    [field[next_example:upper]
-                                     for field in self.ds.fields])
+                minibatch = Example(self.ds._fields.keys(),
+                                    [field[self.next_example:upper]
+                                     for field in self.ds._fields])
                 self.next_example+=minibatch_size
                 return DataSetFields(MinibatchDataSet(minibatch),fieldnames)