Mercurial > pylearn
changeset 15:88168361a5ab
comment re: ArrayDataSet.__array__
author | bergstrj@iro.umontreal.ca |
---|---|
date | Tue, 25 Mar 2008 13:38:51 -0400 |
parents | 80bf5492e571 |
children | 813723310d75 |
files | dataset.py |
diffstat | 1 files changed, 9 insertions(+), 0 deletions(-) [+] |
line wrap: on
line diff
--- a/dataset.py Tue Mar 25 11:39:02 2008 -0400 +++ b/dataset.py Tue Mar 25 13:38:51 2008 -0400 @@ -191,6 +191,15 @@ return ArrayDataSet(data=self.data[apply(slice,slice_args)],fields=self.fields) def __array__(self): + """Return an view of this dataset which is an numpy.ndarray + + Numpy uses this special function name to retrieve an ndarray view for + function such as numpy.sum, numpy.dot, numpy.asarray, etc. + + If this dataset has no fields, then we simply return self.data, + otherwise things are complicated. + - why do we want this behaviour when there are fields? (JB) + """ if not self.fields: return self.data # else, select subsets of columns mapped by the fields