# HG changeset patch # User Frederic Bastien # Date 1209736538 14400 # Node ID a8b70a9117ad6973507a04f26e83648bf2a67e62 # Parent 9165d86855ab8b5d065c2ad7d3e54b239e46a1f3 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... diff -r 9165d86855ab -r a8b70a9117ad dataset.py --- 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)