diff dataset.py @ 188:f01ac276c6fb

added __contains__ to Dataset, added parent constructor call to ArrayDataSet
author James Bergstra <bergstrj@iro.umontreal.ca>
date Wed, 14 May 2008 14:49:08 -0400
parents 895b4b60f5e8
children cb6b945acf5a
line wrap: on
line diff
--- a/dataset.py	Wed May 14 11:51:08 2008 -0400
+++ b/dataset.py	Wed May 14 14:49:08 2008 -0400
@@ -207,6 +207,9 @@
         """
         return DataSet.MinibatchToSingleExampleIterator(self.minibatches(None, minibatch_size = 1))
 
+    def __contains__(self, fieldname):
+        return (fieldname in self.fieldNames()) \
+                or (fieldname in self.attributeNames())
 
     class MinibatchWrapAroundIterator(object):
         """
@@ -937,13 +940,14 @@
     values are (N-2)-dimensional objects (i.e. ordinary numbers if N=2).
     """
 
-    def __init__(self, data_array, fields_columns):
+    def __init__(self, data_array, fields_columns, **kwargs):
         """
         Construct an ArrayDataSet from the underlying numpy array (data) and
         a map (fields_columns) from fieldnames to field columns. The columns of a field are specified
         using the standard arguments for indexing/slicing: integer for a column index,
         slice for an interval of columns (with possible stride), or iterable of column indices.
         """
+        ArrayFieldsDataSet.__init__(self, **kwargs)
         self.data=data_array
         self.fields_columns=fields_columns