diff dataset.py @ 211:bd728c83faff

in __get__, problem if the i.stop was None, i being the slice, added one line replacing None by the len(self)
author Thierry Bertin-Mahieux <bertinmt@iro.umontreal.ca>
date Wed, 21 May 2008 17:39:30 -0400
parents 80731832c62b
children 4b7e89b75e2b
line wrap: on
line diff
--- a/dataset.py	Sat May 17 00:01:47 2008 -0400
+++ b/dataset.py	Wed May 21 17:39:30 2008 -0400
@@ -442,7 +442,9 @@
         rows=None
         # or a slice
         if type(i) is slice:
+            #print 'i=',i
             if not i.start: i=slice(0,i.stop,i.step)
+            if not i.stop: i=slice(i.start,len(self),i.step)
             if not i.step: i=slice(i.start,i.stop,1)
             if i.step is 1:
                 return self.minibatches(minibatch_size=i.stop-i.start,n_batches=1,offset=i.start).next().examples()
@@ -662,6 +664,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
         assert len(fields_lookuplist)>0
         self.length=len(fields_lookuplist[0])
@@ -1140,6 +1143,9 @@
       Note that the expected semantics of the function differs in minibatch mode
       (it takes minibatches of inputs and produces minibatches of outputs, as
       documented in the class comment).
+
+      TBM: are filedtypes the old field types (from input_dataset) or the new ones
+      (for the new dataset created)?
       """
       self.input_dataset=input_dataset
       self.function=function
@@ -1182,6 +1188,7 @@
                   return all_outputs
               return Example(fieldnames,[all_outputs[name] for name in fieldnames])
 
+
       return ApplyFunctionIterator(self)
 
   def __iter__(self): # only implemented for increased efficiency