# HG changeset patch # User Frederic Bastien # Date 1212422381 14400 # Node ID c8f19a9eb10fac6eec3cf7c77f4e2476a1c25c24 # Parent ef70a665aaaf416db6a4cc4f27abd202f050a214 Optimisation in ArrayDataSet::__getitem__ diff -r ef70a665aaaf -r c8f19a9eb10f dataset.py --- a/dataset.py Fri May 30 10:19:16 2008 -0400 +++ b/dataset.py Mon Jun 02 11:59:41 2008 -0400 @@ -1016,12 +1016,13 @@ def __getitem__(self,key): """More efficient implementation than the default __getitem__""" fieldnames=self.fields_columns.keys() + values=self.fields_columns.values() if type(key) is int: return Example(fieldnames, - [self.data[key,self.fields_columns[f]] for f in fieldnames]) + [self.data[key,col] for col in values]) if type(key) is slice: return MinibatchDataSet(Example(fieldnames, - [self.data[key,self.fields_columns[f]] for f in fieldnames])) + [self.data[key,col] for col in values])) if type(key) is list: for i in range(len(key)): if self.hasFields(key[i]): @@ -1030,9 +1031,10 @@ #we must separate differently for list as numpy # doesn't support self.data[[i1,...],[i2,...]] # when their is more then two i1 and i2 - [self.data[key,:][:,self.fields_columns[f]] - if isinstance(self.fields_columns[f],list) else - self.data[key,self.fields_columns[f]] for f in fieldnames]), + [self.data[key,:][:,col] + if isinstance(col,list) else + self.data[key,col] for col in values]), + self.valuesVStack,self.valuesHStack)