Mercurial > pylearn
comparison dataset.py @ 140:488ad6398b12
bugfix
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 12 May 2008 14:13:19 -0400 |
parents | fa752c55aa09 |
children | f5f235bebee4 |
comparison
equal
deleted
inserted
replaced
139:0c6fec172ae1 | 140:488ad6398b12 |
---|---|
763 self.iterators=iterators | 763 self.iterators=iterators |
764 def __iter__(self): | 764 def __iter__(self): |
765 return self | 765 return self |
766 def next(self): | 766 def next(self): |
767 # concatenate all the fields of the minibatches | 767 # concatenate all the fields of the minibatches |
768 l=LookupList() | |
769 for iter in self.iterators: | |
770 l.append_lookuplist(iter.next()) | |
771 return l | |
768 return reduce(LookupList.__add__,[iterator.next() for iterator in self.iterators]) | 772 return reduce(LookupList.__add__,[iterator.next() for iterator in self.iterators]) |
769 | 773 |
770 assert self.hasFields(*fieldnames) | 774 assert self.hasFields(*fieldnames) |
771 # find out which underlying datasets are necessary to service the required fields | 775 # find out which underlying datasets are necessary to service the required fields |
772 # and construct corresponding minibatch iterators | 776 # and construct corresponding minibatch iterators |
773 if fieldnames: | 777 if fieldnames and fieldnames!=self.fieldNames(): |
774 datasets=set([]) | 778 datasets=set([]) |
775 fields_in_dataset=dict([(dataset,[]) for dataset in datasets]) | 779 fields_in_dataset=dict([(dataset,[]) for dataset in datasets]) |
776 for fieldname in fieldnames: | 780 for fieldname in fieldnames: |
777 dataset=self.datasets[self.fieldname2dataset[fieldname]] | 781 dataset=self.datasets[self.fieldname2dataset[fieldname]] |
778 datasets.add(dataset) | 782 datasets.add(dataset) |