[Scipy-svn] r4104 - trunk/scipy/io/arff

scipy-svn@scip... scipy-svn@scip...
Mon Apr 7 19:36:35 CDT 2008


Author: cdavid
Date: 2008-04-07 19:36:31 -0500 (Mon, 07 Apr 2008)
New Revision: 4104

Modified:
   trunk/scipy/io/arff/arffread.py
Log:
A bit more doc for loadarff.

Modified: trunk/scipy/io/arff/arffread.py
===================================================================
--- trunk/scipy/io/arff/arffread.py	2008-04-08 00:15:48 UTC (rev 4103)
+++ trunk/scipy/io/arff/arffread.py	2008-04-08 00:36:31 UTC (rev 4104)
@@ -300,9 +300,26 @@
 class MetaData:
     """Small container to keep useful informations on a ARFF dataset.
     
-    Also maintains the list of attributes in order, i.e. doing for i in meta,
-    where meta is an instance of MetaData, will return the different attribute
-    names in the order they were defined."""
+    Knows about attributes names and types.
+
+    :Example:
+
+        data, meta = loadarff('iris.arff')
+        # This will print the attributes names of the iris.arff dataset
+        for i in meta:
+            print i
+        # This works too
+        meta.names()
+        # Getting attribute type
+        types = meta.types()
+
+    :Note:
+
+        Also maintains the list of attributes in order, i.e. doing for i in
+        meta, where meta is an instance of MetaData, will return the different
+        attribute names in the order they were defined.
+    
+    """
     def __init__(self, rel, attr):
         self.name = rel
         # We need the dictionary to be ordered
@@ -333,9 +350,30 @@
     def __getitem__(self, key):
         return self._attributes[key]
 
+    def names(self):
+        """Return the list of attribute names."""
+        return self._attrnames
+
+    def types(self):
+        """Return the list of attribute types."""
+        return [v[0] for v in self._attributes.values()]
+
 def loadarff(filename):
     """Read an arff file.
 
+    :Args:
+
+        filename: str
+            the name of the file
+
+    :Returns:
+
+        data: record array
+            the data of the arff file. Each record corresponds to one attribute.
+        meta: MetaData
+            this contains informations about the arff file, like type and names
+            of attributes, the relation (name of the dataset), etc...
+
     :Note:
 
         This function should be able to read most arff files. Not implemented



More information about the Scipy-svn mailing list