# HG changeset patch # User Thierry Bertin-Mahieux # Date 1213199034 14400 # Node ID ebccfd05ccd51dc872af748d66c05a8464f6ded9 # Parent 923de30457f000a3c9e1e3bc5be955e205f24f1a dataset.subset implemented diff -r 923de30457f0 -r ebccfd05ccd5 dataset.py --- a/dataset.py Wed Jun 11 11:18:14 2008 -0400 +++ b/dataset.py Wed Jun 11 11:43:54 2008 -0400 @@ -506,6 +506,32 @@ # what in the world is i? raise TypeError(i, type(i)) + + """ + Enables the call dataset.subset[a:b:c] that will return a DataSet + around the examples returned by __getitem__(slice(a,b,c)) + + @SEE DataSet.__getsubset(self) + """ + subset = property(lambda s : s.__getsubset(),doc="returns a subset as a DataSet") + + + def __getsubset(self) : + """ + Enables the call data.subset[a:b:c], returns a DataSet. + Default implementation is a simple wrap around __getitem__() using MinibatchDataSet. + + @RETURN DataSet + @SEE DataSet.subset = property(lambda s : s.__getsubset()) + """ + _self = self + class GetSliceReturnsDataSet(object) : + def __getitem__(self,slice) : + return MinibatchDataSet(_self.__getitem__(slice)) + return GetSliceReturnsDataSet() + + + def valuesHStack(self,fieldnames,fieldvalues): """ Return a value that corresponds to concatenating (horizontally) several field values.