[Scipy-svn] r3749 - branches/io_new
scipy-svn at scipy.org
scipy-svn at scipy.org
Sun Dec 30 06:09:53 EST 2007
Author: oliphant
Date: 2007-12-30 05:09:48 -0600 (Sun, 30 Dec 2007)
New Revision: 3749
Modified:
branches/io_new/__init__.py
branches/io_new/setup.py
Log:
Make more changes to the scipy.io branch --- added docs to deprecate_with_docs.
Modified: branches/io_new/__init__.py
===================================================================
--- branches/io_new/__init__.py 2007-12-30 08:41:21 UTC (rev 3748)
+++ branches/io_new/__init__.py 2007-12-30 11:09:48 UTC (rev 3749)
@@ -4,19 +4,72 @@
from info import __doc__
-# snip on----- DELETE after numpy.deprecate_with_doc is available
-import numpy
-numpy.deprecate_with_doc = lambda doc: (lambda func: func)
-# snip off---- DELETE after numpy.deprecate_with_doc is available
-
from numpy import deprecate_with_doc
from numpyio import packbits, unpackbits, bswap, fread, fwrite, \
convert_objectarray
-fread = deprecate_with_doc('')(fread)
-fwrite = deprecate_with_doc('')(fwrite)
-bswap = deprecate_with_doc('')(bswap)
+fread = deprecate_with_doc(\
+"""
+scipy.io.fread is easily replaced with raw reading capabilities of NumPy
+including fromfile as well as memory-mapping capabilities.
+""")(fread)
+
+fwrite = deprecate_with_doc(\
+"""
+
+scipy.io.fwrite is easily replaced with raw writing capabilities of
+NumPy. Also, remmber that files can be directly memory-mapped into NumPy
+arrays which is often a better way of "reading" especially large files.
+
+Look at the tofile methods as well as save and savez for writing arrays into
+easily transported files of data.
+""")(fwrite)
+
+bswap = deprecate_with_doc(\
+"""
+
+scipy.io.bswap is easily replaced with the byteswap method on an array.
+out = scipy.io.bswap(arr) --> out = arr.byteswap(True)
+""")(bswap)
+
+packbits = deprecate_with_doc(\
+"""
+
+The functionality of scipy.io.packbits is now available as numpy.packbits
+The calling convention is a bit different as the 2-d case is not specialized.
+
+However, you can simulate scipy.packbits by raveling the last 2 dimensions
+of the array and calling numpy.packbits with an axis=-1 keyword:
+
+def scipy_packbits(inp):
+ a = np.asarray(inp)
+ if a.ndim < 2:
+ return np.packbits(a)
+ oldshape = a.shape
+ newshape = oldshape[:-2] + (oldshape[-2]*oldshape[-1],)
+ a = np.reshape(a, newshape)
+ return np.packbits(a, axis=-1).ravel()
+""")(packbits)
+
+unpackbits = deprecate_with_doc(\
+"""
+
+The functionality of scipy.io.unpackbits is now available in numpy.unpackbits
+The calling convention is different however as the 2-d case is no longer
+specialized.
+
+Thus, the scipy.unpackbits behavior must be simulated using numpy.unpackbits.
+
+def scipy_unpackbits(inp, els_per_slice, out_type=None):
+ inp = np.asarray(inp)
+ num4els = ((els_per_slice-1) >> 3) + 1
+ inp = np.reshape(inp, (-1,num4els))
+ res = np.unpackbits(inp, axis=-1)[:,:els_per_slice]
+ return res.ravel()
+""")(unpackbits)
+convert_objectarray = deprecate_with_doc(convert_objectarray)
+
# matfile read and write
from matlab.mio import loadmat, savemat
@@ -28,7 +81,7 @@
from recaster import sctype_attributes, Recaster
from array_import import read_array, write_array
-from data_store import save as save_as_module
+from data_store import save, save_as_module
from data_store import load, create_module, create_shelf
from pickler import objload, objsave
Modified: branches/io_new/setup.py
===================================================================
--- branches/io_new/setup.py 2007-12-30 08:41:21 UTC (rev 3748)
+++ branches/io_new/setup.py 2007-12-30 11:09:48 UTC (rev 3749)
@@ -10,6 +10,7 @@
config.add_data_dir('tests')
config.add_data_dir('examples')
config.add_data_dir('docs')
+ config.add_subpackage('matlab')
return config
if __name__ == '__main__':
More information about the Scipy-svn
mailing list