[Numpy-svn] r2958 - trunk/numpy/oldnumeric

numpy-svn at scipy.org numpy-svn at scipy.org
Fri Aug 4 20:52:58 CDT 2006


Author: oliphant
Date: 2006-08-04 20:52:55 -0500 (Fri, 04 Aug 2006)
New Revision: 2958

Modified:
   trunk/numpy/oldnumeric/compat.py
   trunk/numpy/oldnumeric/functions.py
   trunk/numpy/oldnumeric/misc.py
Log:
Fix-up oldnumeric compatibility layer.

Modified: trunk/numpy/oldnumeric/compat.py
===================================================================
--- trunk/numpy/oldnumeric/compat.py	2006-08-05 01:20:56 UTC (rev 2957)
+++ trunk/numpy/oldnumeric/compat.py	2006-08-05 01:52:55 UTC (rev 2958)
@@ -5,7 +5,7 @@
            'LittleEndian',
            'sarray', 'arrayrange', 'cross_correlate',
            'matrixmultiply', 'outerproduct', 'innerproduct',
-           'cross_product', 'array_constructor',
+           'cross_product', 'array_constructor', 'pickle_array',
            'DumpArray', 'LoadArray', 'multiarray', 'divide_safe',
            # from cPickle
            'dump', 'dumps'
@@ -70,4 +70,11 @@
     else:
         return x
 
-
+def pickle_array(a):
+    if a.dtype.hasobject:
+        return (array_constructor,
+                a.shape, a.dtype.char, a.tolist(), LittleEndian)
+    else:
+        return (array_constructor,
+                (a.shape, a.dtype.char, a.tostring(), LittleEndian))
+    

Modified: trunk/numpy/oldnumeric/functions.py
===================================================================
--- trunk/numpy/oldnumeric/functions.py	2006-08-05 01:20:56 UTC (rev 2957)
+++ trunk/numpy/oldnumeric/functions.py	2006-08-05 01:52:55 UTC (rev 2958)
@@ -1,4 +1,4 @@
-# Functions that should behave the same as Numeric
+# Functions that should behave the same as Numeric and need changing
 
 import numpy as N
 import numpy.core.multiarray as mu
@@ -7,7 +7,9 @@
 
 __all__ = ['take', 'repeat', 'sum', 'product', 'sometrue', 'alltrue',
            'cumsum', 'cumproduct']
-__all__ += ['ones', 'empty', 'identity', 'zeros']
+__all__ += ['ones', 'empty', 'identity', 'zeros', 'array', 'asarray', 'nonzero',
+            'reshape', 'arange', 'fromstring', 'ravel', 'trace', 'indices',
+            'where']
 
 def take(a, indicies, axis=0):
     return N.take(a, indicies, axis)
@@ -60,3 +62,33 @@
     dtype = convtypecode(typecode, dtype)    
     return mu.empty(shape, dtype, order)
 
+
+def array(sequence, typecode=None, copy=1, savespace=0):
+    pass
+
+def asarray(a, typecode=None):
+    pass
+
+def nonzero(a):
+    pass
+
+def reshape(a, shape):
+    pass
+
+def arange(start, stop=None, step=1, typecode=None):
+    pass
+
+def fromstring(string, typecode='l', count=-1):
+    pass
+
+def ravel(m):
+    pass
+
+def trace(a, offset=0, axis1=0, axis2=1):
+    pass
+
+def indices(dimensions, typecode=None):
+    pass
+
+def where(condition, x, y):
+    pass

Modified: trunk/numpy/oldnumeric/misc.py
===================================================================
--- trunk/numpy/oldnumeric/misc.py	2006-08-05 01:20:56 UTC (rev 2957)
+++ trunk/numpy/oldnumeric/misc.py	2006-08-05 01:52:55 UTC (rev 2958)
@@ -1,3 +1,40 @@
+# Functions that already have the correct syntax or miscellaneous functions
 
 
-__all__ = ['load', 'sort', 'copy_reg', 'clip', 'putmask', 'Unpickler', 'rank', 'sign', 'shape', 'types', 'array', 'allclose', 'size', 'nonzero', 'asarray', 'reshape', 'argmax', 'choose', 'swapaxes', 'array_str', 'pi', 'ravel', 'math', 'compress', 'concatenate', 'pickle_array', 'around', 'trace', 'vdot', 'transpose', 'array2string', 'diagonal', 'searchsorted', 'put', 'fromfunction', 'copy', 'resize', 'array_repr', 'e', 'argmin', 'StringIO', 'pickle', 'average', 'arange', 'argsort', 'convolve', 'fromstring', 'indices', 'loads', 'Pickler', 'where', 'dot']
+__all__ = ['load', 'sort', 'copy_reg', 'clip', 'putmask', 'Unpickler', 'rank',
+           'sign', 'shape', 'types', 
+           'argmax', 'choose', 'swapaxes', 'array_str',
+           'pi', 'math', 'compress', 'concatenate'
+           'around', 'vdot', 'transpose', 'array2string', 'diagonal',
+           'searchsorted', 'put', 'fromfunction', 'copy', 'resize',
+           'array_repr', 'e', 'argmin', 'StringIO', 'pickle', 'average',
+           'argsort', 'convolve', 'loads',
+           'Pickler', 'dot']
+
+import types
+import StringIO
+import pickle
+import math
+import copy
+import copy_reg
+from pickle import load, loads
+
+from numpy import sort, clip, putmask, rank, sign, shape, allclose, size,\
+     argmax, choose, swapaxes, array_str, array_repr, argmin, e, pi, \
+     fromfunction, resize, around, compress, concatenate, vdot, transpose, \
+     diagonal, searchsorted, put, average, argsort, convolve, dot
+
+from array_printer import array2string
+
+
+class Unpickler(pickle.Unpickler):
+    def __init__(self, *args, **kwds):
+        raise NotImplemented    
+    def load_array(self):
+        raise NotImplemented
+
+class Pickler(pickle.Pickler):
+    def __init__(self, *args, **kwds):
+        raise NotImplemented
+    def save_array(self, object):
+        raise NotImplemented



More information about the Numpy-svn mailing list