diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-08-05 01:52:55 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-08-05 01:52:55 +0000 |
commit | 65343e533fbf10a5f93970497065478e24ee6238 (patch) | |
tree | dc0d6510d62983cfb041a4ad257c2973dbf01983 | |
parent | 9d8e2024ff9014fa2fd9a29812cec615dff6feb9 (diff) | |
download | numpy-65343e533fbf10a5f93970497065478e24ee6238.tar.gz |
Fix-up oldnumeric compatibility layer.
-rw-r--r-- | numpy/oldnumeric/compat.py | 11 | ||||
-rw-r--r-- | numpy/oldnumeric/functions.py | 36 | ||||
-rw-r--r-- | numpy/oldnumeric/misc.py | 39 |
3 files changed, 81 insertions, 5 deletions
diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py index ebc978fee..69941bb09 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -5,7 +5,7 @@ __all__ = ['NewAxis', '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 @@ def array_constructor(shape, typecode, thestr, Endian=LittleEndian): 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)) + diff --git a/numpy/oldnumeric/functions.py b/numpy/oldnumeric/functions.py index a905aa9a7..8b9828664 100644 --- a/numpy/oldnumeric/functions.py +++ b/numpy/oldnumeric/functions.py @@ -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 @@ from typeconv import convtypecode __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 @@ def empty(shape, typecode='l', dtype=None): 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 diff --git a/numpy/oldnumeric/misc.py b/numpy/oldnumeric/misc.py index d6361ef4c..ee0c0e168 100644 --- a/numpy/oldnumeric/misc.py +++ b/numpy/oldnumeric/misc.py @@ -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 |