diff dataset.py @ 8:d1c394486037

Replaced asarray() method by __array__ method which gets called automatically when trying to cast into an array or numpy array or upon numpy.asarray(dataset).
author bengioy@bengiomac.local
date Mon, 24 Mar 2008 15:56:53 -0400
parents 6f8f338686db
children de616c423dbd
line wrap: on
line diff
--- a/dataset.py	Mon Mar 24 13:20:15 2008 -0400
+++ b/dataset.py	Mon Mar 24 15:56:53 2008 -0400
@@ -107,7 +107,7 @@
     must correspond to a slice of columns. If the dataset has fields,
     each 'example' is just a one-row ArrayDataSet, otherwise it is a numpy array.
     Any dataset can also be converted to a numpy array (losing the notion of fields)
-    by the asarray(dataset) call.
+    by the numpy.array(dataset) call.
     """
 
     def __init__(self,dataset=None,data=None,fields={},minibatch_size=1):
@@ -187,7 +187,7 @@
         """dataset[i:j] returns the subdataset with examples i,i+1,...,j-1."""
         return ArrayDataSet(data=self.data[apply(slice,slice_args)],fields=self.fields)
 
-    def asarray(self):
+    def __array__(self):
         if not self.fields:
             return self.data
         # else, select subsets of columns mapped by the fields