Mercurial > pylearn
changeset 144:ceae4de18981
Automated merge with ssh://p-omega1@lgcm.iro.umontreal.ca/tlearn
author | Frederic Bastien <bastienf@iro.umontreal.ca> |
---|---|
date | Mon, 12 May 2008 15:08:18 -0400 |
parents | 0d8e721cc63c (current diff) b7ca3545186b (diff) |
children | 933db7ece663 8173e196e291 |
files | dataset.py learner.py |
diffstat | 4 files changed, 37 insertions(+), 8 deletions(-) [+] |
line wrap: on
line diff
--- a/dataset.py Mon May 12 14:30:21 2008 -0400 +++ b/dataset.py Mon May 12 15:08:18 2008 -0400 @@ -770,16 +770,19 @@ return self def next(self): # concatenate all the fields of the minibatches - return reduce(LookupList.__add__,[iterator.next() for iterator in self.iterators]) + l=LookupList() + for iter in self.iterators: + l.append_lookuplist(iter.next()) + return l assert self.hasFields(*fieldnames) # find out which underlying datasets are necessary to service the required fields # and construct corresponding minibatch iterators - if fieldnames: + if fieldnames and fieldnames!=self.fieldNames(): datasets=set([]) fields_in_dataset=dict([(dataset,[]) for dataset in datasets]) for fieldname in fieldnames: - dataset=self.datasets[self.fieldnames2dataset[fieldname]] + dataset=self.datasets[self.fieldname2dataset[fieldname]] datasets.add(dataset) fields_in_dataset[dataset].append(fieldname) datasets=list(datasets)
--- a/learner.py Mon May 12 14:30:21 2008 -0400 +++ b/learner.py Mon May 12 15:08:18 2008 -0400 @@ -124,6 +124,8 @@ The function returned makes use of the self.useInputAttributes() and sets the attributes specified by self.useOutputAttributes(). """ + raise AbstractFunction() + def attributeNames(self): """ A Learner may have attributes that it wishes to export to other objects. To automate
--- a/lookup_list.py Mon May 12 14:30:21 2008 -0400 +++ b/lookup_list.py Mon May 12 15:08:18 2008 -0400 @@ -71,6 +71,12 @@ self._values.append(value) self._names.append(key) + def append_lookuplist(self, *list): + for l in list: + for key in l.keys(): + self.append_keyval(key,l[key]) + del l + def __len__(self): return len(self._values) @@ -103,3 +109,15 @@ Return a list of values associated with the given names (which must all be keys of the lookup list). """ return [self[name] for name in names] + + +if __name__ == '__main__': + + a=LookupList(['a'],[1]) + print a + b=LookupList(['b'],[2]) + print b + a.append_lookuplist(b) + print a + a.append_lookuplist(b) + print a
--- a/test_dataset.py Mon May 12 14:30:21 2008 -0400 +++ b/test_dataset.py Mon May 12 15:08:18 2008 -0400 @@ -320,11 +320,17 @@ # - 'fieldtypes': a list of types (one per field) #* ds1 | ds2 | ds3 == ds.hstack([ds1,ds2,ds3])#???? - i=0 - for example in hstack([ds('x'),ds('y'),ds('z')]): - example==ds[i] - i+=1 - del i,example + #hstack([ds('x','y'),ds('z')] + #hstack([ds('z','y'),ds('x')] + #assert have_thrown("hstack([ds('x'),ds('x')]") + #assert not have_thrown("hstack([ds('x'),ds('x')]") + #accept_nonunique_names + #assert have_thrown("hstack([ds('y','x'),ds('x')]") +# i=0 +# for example in hstack([ds('x'),ds('y'),ds('z')]): +# example==ds[i] +# i+=1 +# del i,example #* ds1 & ds2 & ds3 == ds.vstack([ds1,ds2,ds3])#????