[Scipy-svn] r6886 - in trunk/scipy/io: . arff matlab
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Nov 14 04:59:33 EST 2010
Author: rgommers
Date: 2010-11-14 03:59:33 -0600 (Sun, 14 Nov 2010)
New Revision: 6886
Modified:
trunk/scipy/io/__init__.py
trunk/scipy/io/arff/__init__.py
trunk/scipy/io/data_store.py
trunk/scipy/io/matlab/__init__.py
trunk/scipy/io/matlab/mio.py
trunk/scipy/io/netcdf.py
trunk/scipy/io/wavfile.py
Log:
DOC: merge more wiki edits for io module.
Modified: trunk/scipy/io/__init__.py
===================================================================
--- trunk/scipy/io/__init__.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/__init__.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -1,3 +1,47 @@
+"""
+Data input and output
+
+SciPy has many modules, classes, and functions available to read data
+from and write data to a variety of file formats.
+
+Modules
+-------
+
+.. autosummary::
+ :toctree: generated/
+
+ arff - Read ARFF files, the standard data format for WEKA
+ byteordercodes - System byteorder utilities - NumPy byteorder encoding
+ data_store - Load or save values to a file
+ dumbdbm_patched - A dumb and slow but simple dbm clone
+ matlab - Utilities for dealing with MATLAB(R) files
+ mmio - Matrix Market I/O in Python
+ netcdf - NetCDF reader/writer module
+ wavfile - module to read / write wav files using numpy arrays
+
+Classes
+-------
+
+.. autosummary::
+ :toctree: generated/
+
+ netcdf_file - A file object for NetCDF data
+ netcdf_variable - A data object for the netcdf module
+
+Functions
+---------
+
+.. autosummary::
+ :toctree: generated/
+
+ loadmat - Read a MATLAB style mat file (version 4 through 7.1)
+ savemat - Write a MATLAB style mat file (version 4 through 7.1)
+ mminfo - Query matrix info from Matrix Market formatted file
+ mmread - Read matrix from Matrix Market formatted file
+ mmwrite - Write matrix to Matrix Market formatted file
+ save_as_module - Data saved as module, accessed on load as attirbutes
+
+"""
#
# io - Data input and output
#
Modified: trunk/scipy/io/arff/__init__.py
===================================================================
--- trunk/scipy/io/arff/__init__.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/arff/__init__.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -1,11 +1,42 @@
-"""Module to read arff files (weka format).
+"""
+Module to read ARFF files, which are the standard data format for WEKA.
-arff is a simple file format which support numerical, string and data values.
-It supports sparse data too.
+ARFF is a text file format which support numerical, string and data values.
+The format can also represent missing data and sparse data.
-See http://weka.sourceforge.net/wekadoc/index.php/en:ARFF_(3.4.6) for more
-details about arff format and available datasets."""
+See the `WEKA website
+<http://weka.wikispaces.com/ARFF>`_
+for more details about arff format and available datasets.
+Examples
+--------
+
+>>> from scipy.io import arff
+>>> content = \"\"\"
+... @relation foo
+... @attribute width numeric
+... @attribute height numeric
+... @attribute color {red,green,blue,yellow,black}
+... @data
+... 5.0,3.25,blue
+... 4.5,3.75,green
+... 3.0,4.00,red
+... \"\"\"
+>>> f = open('testdata.arff', 'w')
+>>> f.write(content)
+>>> f.close()
+>>> data, meta = arff.loadarff('testdata.arff')
+>>> data
+array([(5.0, 3.25, 'blue'), (4.5, 3.75, 'green'), (3.0, 4.0, 'red')],
+ dtype=[('width', '<f8'), ('height', '<f8'), ('color', '|S6')])
+>>> meta
+Dataset: foo
+\twidth's type is numeric
+\theight's type is numeric
+\tcolor's type is nominal, range is ('red', 'green', 'blue', 'yellow', 'black')
+
+"""
+
from arffread import *
import arffread
Modified: trunk/scipy/io/data_store.py
===================================================================
--- trunk/scipy/io/data_store.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/data_store.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -1,18 +1,29 @@
-""" Load or save values to a file.
+"""
+Load or save values to a file.
- Shelves work well for storing data, but they are slow to access
- repeatedly - especially for large data sets. This module allows
- you to store data to a file and then load it back into the workspace.
- When the data is stored, a python module is also created as the
- "namespace for the data"
- >>> import scipy.io
- >>> import os
- >>> a = 1
- >>> scipy.io.save_as_module('c:/temp/junker',{'a':a})
- >>> os.chdir('c:/temp')
- >>> import junker
- >>> junker.a
- 1
+Shelves work well for storing data, but they are slow to access
+repeatedly - especially for large data sets. This module allows
+you to store data to a file and then load it back into the workspace.
+When the data is stored, a python module is also created as the
+"namespace for the data"
+
+
+Examples
+--------
+
+Saving the data to a data store:
+
+>>> import scipy.io
+>>> import os
+>>> a = 1
+>>> scipy.io.save_as_module('junker', {'a':a})
+
+Loading the data saved to a data store in the same directory:
+
+>>> import junker
+>>> print junker.a
+1
+
"""
__all__ = ['save_as_module']
Modified: trunk/scipy/io/matlab/__init__.py
===================================================================
--- trunk/scipy/io/matlab/__init__.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/matlab/__init__.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -1,3 +1,12 @@
+"""
+Utilities for dealing with MATLAB(R) files
+
+Notes
+-----
+MATLAB(R) is a registered trademark of The MathWorks, Inc., 3 Apple Hill
+Drive, Natick, MA 01760-2098, USA.
+
+"""
# Matlab file read and write utilities
from mio import loadmat, savemat
Modified: trunk/scipy/io/matlab/mio.py
===================================================================
--- trunk/scipy/io/matlab/mio.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/matlab/mio.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -1,3 +1,4 @@
+"""Module for reading and writing MATLAB .mat files"""
# Authors: Travis Oliphant, Matthew Brett
"""
Modified: trunk/scipy/io/netcdf.py
===================================================================
--- trunk/scipy/io/netcdf.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/netcdf.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -684,22 +684,51 @@
class netcdf_variable(object):
"""
- ``netcdf_variable`` objects are constructed by calling the method
- ``createVariable`` on the netcdf_file object.
+ A data object for the `netcdf` module.
- ``netcdf_variable`` objects behave much like array objects defined in
- Numpy, except that their data resides in a file. Data is read by
- indexing and written by assigning to an indexed subset; the entire
- array can be accessed by the index ``[:]`` or using the methods
- ``getValue`` and ``assignValue``. ``netcdf_variable`` objects also
- have attribute ``shape`` with the same meaning as for arrays, but
- the shape cannot be modified. There is another read-only attribute
- ``dimensions``, whose value is the tuple of dimension names.
+ `netcdf_variable` objects are constructed by calling the method
+ `netcdf_file.createVariable` on the `netcdf_file` object. `netcdf_variable`
+ objects behave much like array objects defined in numpy, except that their
+ data resides in a file. Data is read by indexing and written by assigning
+ to an indexed subset; the entire array can be accessed by the index ``[:]``
+ or (for scalars) by using the methods `getValue` and `assignValue`.
+ `netcdf_variable` objects also have attribute `shape` with the same meaning
+ as for arrays, but the shape cannot be modified. There is another read-only
+ attribute `dimensions`, whose value is the tuple of dimension names.
All other attributes correspond to variable attributes defined in
the NetCDF file. Variable attributes are created by assigning to an
- attribute of the ``netcdf_variable`` object.
+ attribute of the `netcdf_variable` object.
+ Parameters
+ ----------
+ data : array_like
+ The data array that holds the values for the variable.
+ Typically, this is initialized as empty, but with the proper shape.
+ typecode : dtype character code
+ Desired data-type for the data array.
+ shape : sequence of ints
+ The shape of the array. This should match the lengths of the
+ variable's dimensions.
+ dimensions : sequence of strings
+ The names of the dimensions used by the variable. Must be in the
+ same order of the dimension lengths given by `shape`.
+ attributes : dict, optional
+ Attribute values (any type) keyed by string names. These attributes
+ become attributes for the netcdf_variable object.
+
+
+ Attributes
+ ----------
+ dimensions : list of str
+ List of names of dimensions used by the variable object.
+ isrec, shape
+ Properties
+
+ See also
+ --------
+ isrec, shape
+
"""
def __init__(self, data, typecode, shape, dimensions, attributes=None):
self.data = data
Modified: trunk/scipy/io/wavfile.py
===================================================================
--- trunk/scipy/io/wavfile.py 2010-11-14 09:59:06 UTC (rev 6885)
+++ trunk/scipy/io/wavfile.py 2010-11-14 09:59:33 UTC (rev 6886)
@@ -3,9 +3,9 @@
Functions
---------
-read: Return the sample rate (in samples/sec) and data from a WAV file.
+`read`: Return the sample rate (in samples/sec) and data from a WAV file.
-write: Write a numpy array as a WAV file.
+`write`: Write a numpy array as a WAV file.
"""
import numpy
More information about the Scipy-svn
mailing list