comparison lookup_list.py @ 134:3f4e5c9bdc5e

Fixes to ApplyFunctionDataSet and other things to make learner and mlp work
author Yoshua Bengio <bengioy@iro.umontreal.ca>
date Fri, 09 May 2008 17:38:57 -0400
parents b4657441dd65
children ad144fa72bf5
comparison
equal deleted inserted replaced
133:b4657441dd65 134:3f4e5c9bdc5e
47 def __getitem__(self,key): 47 def __getitem__(self,key):
48 """ 48 """
49 The key in example[key] can either be an integer to index the fields 49 The key in example[key] can either be an integer to index the fields
50 or the name of the field. 50 or the name of the field.
51 """ 51 """
52 if isinstance(key,int) or isinstance(key,slice) or isinstance(key,list): 52 if isinstance(key,int) or isinstance(key,slice) or (isinstance(key,list) and all([isinstance(i,int) for i in key])):
53 return self._values[key] 53 return self._values[key]
54 else: # if not an int, key must be a name 54 else: # if not an int, key must be a name
55 # expecting key to be a valid field name 55 # expecting key to be a valid field name
56 assert isinstance(key,str) 56 assert isinstance(key,str)
57 return self._values[self._name2index[key]] 57 return self._values[self._name2index[key]]