summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-06-12 22:58:43 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-06-12 22:58:43 +0000
commitfbf0b479604c22e60215bb28cdedabfb821b9d75 (patch)
treeff1c02a4a21aec9998b57d7aff01a34573aa21c2
parentb5e35c7c5c715d58aca9638e40098d044b8b8dba (diff)
downloadnumpy-fbf0b479604c22e60215bb28cdedabfb821b9d75.tar.gz
Check-in name-space changes so that numpy.oldnumeric is the compatibility module and numpy does not contain all of the names.
-rw-r--r--numpy/__init__.py4
-rw-r--r--numpy/core/__init__.py4
-rw-r--r--numpy/core/arrayprint.py2
-rw-r--r--numpy/core/fromnumeric.py (renamed from numpy/core/oldnumeric.py)138
-rw-r--r--numpy/core/ma.py68
-rw-r--r--numpy/core/numeric.py6
-rw-r--r--numpy/core/numerictypes.py11
-rw-r--r--numpy/core/tests/test_ma.py2
-rw-r--r--numpy/core/tests/test_oldnumeric.py29
-rw-r--r--numpy/lib/convertcode.py4
-rw-r--r--numpy/lib/function_base.py6
-rw-r--r--numpy/lib/machar.py2
-rw-r--r--numpy/lib/mlab.py3
-rw-r--r--numpy/lib/shape_base.py2
-rw-r--r--numpy/oldnumeric/compat.py171
-rw-r--r--numpy/oldnumeric/tests/test_oldnumeric.py86
-rw-r--r--numpy/random/oldrngstats.py2
-rw-r--r--numpy/setup.py1
18 files changed, 321 insertions, 220 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index 96edd88c2..db5548380 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -3,7 +3,7 @@ NumPy
==========
You can support the development of NumPy and SciPy by purchasing
-documentation at
+extended documentation at
http://www.trelgol.com
@@ -33,7 +33,7 @@ else:
pkgload = PackageLoader()
pkgload('testing','core','lib','linalg','dft','random','f2py',
verbose=NUMPY_IMPORT_VERBOSE,postpone=False)
-
+
if __doc__ is not None:
__doc__ += """
diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py
index b8c5f962e..56f89b114 100644
--- a/numpy/core/__init__.py
+++ b/numpy/core/__init__.py
@@ -8,7 +8,7 @@ import numerictypes as nt
multiarray.set_typeDict(nt.typeDict)
import _sort
from numeric import *
-from oldnumeric import *
+from fromnumeric import *
from defmatrix import *
import ma
import defchararray as char
@@ -22,7 +22,7 @@ del nt
__all__ = ['char','rec','memmap','ma']
__all__ += numeric.__all__
-__all__ += oldnumeric.__all__
+__all__ += fromnumeric.__all__
__all__ += defmatrix.__all__
__all__ += rec.__all__
__all__ += char.__all__
diff --git a/numpy/core/arrayprint.py b/numpy/core/arrayprint.py
index 613f89ed9..136b58c92 100644
--- a/numpy/core/arrayprint.py
+++ b/numpy/core/arrayprint.py
@@ -17,7 +17,7 @@ import numeric as _gen
import numerictypes as _nt
import umath as _uf
from multiarray import format_longfloat
-from oldnumeric import ravel
+from fromnumeric import ravel
_nc = _gen
# The following functions are emergency substitutes for numeric functions
diff --git a/numpy/core/oldnumeric.py b/numpy/core/fromnumeric.py
index ddec9439d..da8fe7f3c 100644
--- a/numpy/core/oldnumeric.py
+++ b/numpy/core/fromnumeric.py
@@ -1,21 +1,6 @@
-# Compatibility module containing deprecated names
+# Module containing non-deprecated functions borrowed from Numeric.
__all__ = ['asarray', 'array', 'concatenate',
- 'NewAxis',
- 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',
- 'LittleEndian', 'Bool',
- 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt',
- 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger',
- # UnsignedInt64 and Unsigned128 added below if possible
- # same for Int64 and Int128, Float128, and Complex128
- 'Int8', 'Int16', 'Int32',
- 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',
- 'PyObject', 'Float32', 'Float64', 'Float16', 'Float8',
- 'Complex32', 'Complex64', 'Complex8', 'Complex16',
- 'typecodes', 'sarray', 'arrayrange', 'cross_correlate',
- 'matrixmultiply', 'outerproduct', 'innerproduct',
- # from cPickle
- 'dump', 'dumps',
# functions that are now methods
'take', 'reshape', 'choose', 'repeat', 'put', 'putmask',
'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin',
@@ -42,132 +27,11 @@ try:
_gentype = types.GeneratorType
except AttributeError:
_gentype = types.NoneType
-#Use this to add a new axis to an array
-#compatibility only
-NewAxis = None
-
-#deprecated
-UFuncType = type(um.sin)
-UfuncType = type(um.sin)
-ArrayType = mu.ndarray
-arraytype = mu.ndarray
-
-LittleEndian = (sys.byteorder == 'little')
# save away Python sum
_sum_ = sum
-# backward compatible names from old Precision.py
-
-Character = 'S1'
-UnsignedInt8 = _dt_(nt.uint8)
-UInt8 = UnsignedInt8
-UnsignedInt16 = _dt_(nt.uint16)
-UInt16 = UnsignedInt16
-UnsignedInt32 = _dt_(nt.uint32)
-UInt32 = UnsignedInt32
-UnsignedInt = _dt_(nt.uint)
-
-try:
- UnsignedInt64 = _dt_(nt.uint64)
-except AttributeError:
- pass
-else:
- UInt64 = UnsignedInt64
- __all__ += ['UnsignedInt64', 'UInt64']
-try:
- UnsignedInt128 = _dt_(nt.uint128)
-except AttributeError:
- pass
-else:
- UInt128 = UnsignedInt128
- __all__ += ['UnsignedInt128','UInt128']
-
-Int8 = _dt_(nt.int8)
-Int16 = _dt_(nt.int16)
-Int32 = _dt_(nt.int32)
-
-try:
- Int64 = _dt_(nt.int64)
-except AttributeError:
- pass
-else:
- __all__ += ['Int64']
-
-try:
- Int128 = _dt_(nt.int128)
-except AttributeError:
- pass
-else:
- __all__ += ['Int128']
-
-Bool = _dt_(bool)
-Int0 = _dt_(int)
-Int = _dt_(int)
-Float0 = _dt_(float)
-Float = _dt_(float)
-Complex0 = _dt_(complex)
-Complex = _dt_(complex)
-PyObject = _dt_(nt.object_)
-Float32 = _dt_(nt.float32)
-Float64 = _dt_(nt.float64)
-
-Float16='f'
-Float8='f'
-UnsignedInteger='L'
-Complex8='F'
-Complex16='F'
-
-try:
- Float128 = _dt_(nt.float128)
-except AttributeError:
- pass
-else:
- __all__ += ['Float128']
-
-Complex32 = _dt_(nt.complex64)
-Complex64 = _dt_(nt.complex128)
-
-try:
- Complex128 = _dt_(nt.complex256)
-except AttributeError:
- pass
-else:
- __all__ += ['Complex128']
-
-typecodes = {'Character':'S1',
- 'Integer':'bhilqp',
- 'UnsignedInteger':'BHILQP',
- 'Float':'fdg',
- 'Complex':'FDG',
- 'AllInteger':'bBhHiIlLqQpP',
- 'AllFloat':'fdgFDG',
- 'All':'?bhilqpBHILQPfdgFDGSUVO'}
-
-def sarray(a, dtype=None, copy=False):
- return array(a, dtype, copy)
-
-def _deprecate(func, oldname, newname):
- import warnings
- def newfunc(*args,**kwds):
- warnings.warn("%s is deprecated, use %s" % (oldname, newname),
- DeprecationWarning)
- return func(*args, **kwds)
- return newfunc
-
-# backward compatibility
-arrayrange = _deprecate(mu.arange, 'arrayrange', 'arange')
-cross_correlate = _deprecate(correlate, 'cross_correlate', 'correlate')
-
-# deprecated names
-matrixmultiply = _deprecate(mu.dot, 'matrixmultiply', 'dot')
-outerproduct = _deprecate(outer, 'outerproduct', 'outer')
-innerproduct = _deprecate(mu.inner, 'innerproduct', 'inner')
-
-from cPickle import dump, dumps
-
# functions that are now methods
-
def _wrapit(obj, method, *args, **kwds):
try:
wrap = obj.__array_wrap__
diff --git a/numpy/core/ma.py b/numpy/core/ma.py
index b17c5d256..4fb7e59c0 100644
--- a/numpy/core/ma.py
+++ b/numpy/core/ma.py
@@ -10,10 +10,10 @@ Adapted for numpy_core 2005 by Travis Oliphant and
import types, sys
import umath
-import oldnumeric
+import fromnumeric
from numeric import newaxis, ndarray, inf
-from oldnumeric import typecodes, amax, amin
-from numerictypes import bool_
+from fromnumeric import amax, amin
+from numerictypes import bool_, typecodes
import numeric
import warnings
@@ -186,7 +186,7 @@ def make_mask (m, copy=0, flag=0):
else:
result = filled(m, True).astype(MaskType)
- if flag and not oldnumeric.sometrue(oldnumeric.ravel(result)):
+ if flag and not fromnumeric.sometrue(fromnumeric.ravel(result)):
return nomask
else:
return result
@@ -348,7 +348,7 @@ class domained_binary_operation:
d2 = filled(b, self.filly)
t = self.domain(d1, d2)
- if oldnumeric.sometrue(t, None):
+ if fromnumeric.sometrue(t, None):
d2 = where(t, self.filly, d2)
mb = mask_or(mb, t)
m = mask_or(ma, mb)
@@ -451,7 +451,7 @@ def nonzero(a):
"""
return asarray(filled(a, 0).nonzero())
-around = masked_unary_operation(oldnumeric.round_)
+around = masked_unary_operation(fromnumeric.round_)
floor = masked_unary_operation(umath.floor)
ceil = masked_unary_operation(umath.ceil)
logical_not = masked_unary_operation(umath.logical_not)
@@ -490,13 +490,13 @@ bitwise_or = masked_binary_operation(umath.bitwise_or)
bitwise_xor = masked_binary_operation(umath.bitwise_xor)
def rank (object):
- return oldnumeric.rank(filled(object))
+ return fromnumeric.rank(filled(object))
def shape (object):
- return oldnumeric.shape(filled(object))
+ return fromnumeric.shape(filled(object))
def size (object, axis=None):
- return oldnumeric.size(filled(object), axis)
+ return fromnumeric.size(filled(object), axis)
class MaskedArray (object):
"""Arrays with possibly masked values.
@@ -580,10 +580,10 @@ class MaskedArray (object):
nd = size(self._data)
if nm != nd:
if nm == 1:
- self._mask = oldnumeric.resize(self._mask, self._data.shape)
+ self._mask = fromnumeric.resize(self._mask, self._data.shape)
self._shared_mask = 0
elif nd == 1:
- self._data = oldnumeric.resize(self._data, self._mask.shape)
+ self._data = fromnumeric.resize(self._data, self._mask.shape)
self._data.shape = self._mask.shape
else:
raise MAError, "Mask and data not compatible."
@@ -596,7 +596,7 @@ class MaskedArray (object):
def __array__ (self, t=None, context=None):
"Special hook for numeric. Converts to numeric if possible."
if self._mask is not nomask:
- if oldnumeric.ravel(self._mask).any():
+ if fromnumeric.ravel(self._mask).any():
if context is None:
warnings.warn("Cannot automatically convert masked array to "\
"numeric because data\n is masked in one or "\
@@ -1177,12 +1177,12 @@ array(data = %(data)s,
def compressed (self):
"A 1-D array of all the non-masked data."
- d = oldnumeric.ravel(self._data)
+ d = fromnumeric.ravel(self._data)
if self._mask is nomask:
return array(d)
else:
- m = 1 - oldnumeric.ravel(self._mask)
- c = oldnumeric.compress(m, d)
+ m = 1 - fromnumeric.ravel(self._mask)
+ c = fromnumeric.compress(m, d)
return array(c, copy=0)
def count (self, axis = None):
@@ -1203,7 +1203,7 @@ array(data = %(data)s,
del t[axis]
return ones(t) * n
if axis is None:
- w = oldnumeric.ravel(m).astype(int)
+ w = fromnumeric.ravel(m).astype(int)
n1 = size(w)
if n1 == 1:
n2 = w[0]
@@ -1254,7 +1254,7 @@ array(data = %(data)s,
#ok, can't put that value in here
value = numeric.array(value, dtype=object)
d = d.astype(object)
- result = oldnumeric.choose(m, (d, value))
+ result = fromnumeric.choose(m, (d, value))
except IndexError:
#ok, if scalar
if d.shape:
@@ -1291,7 +1291,7 @@ array(data = %(data)s,
if self._mask is nomask:
ind = iota
else:
- ind = oldnumeric.compress(1 - self._mask, iota)
+ ind = fromnumeric.compress(1 - self._mask, iota)
d[ind] = filled(values).astype(d.dtype)
def putmask (self, values):
@@ -1358,7 +1358,7 @@ array(data = %(data)s,
def item(self):
"Return Python scalar if possible."
if self._mask is not nomask:
- m = oldnumeric.ravel(self._mask)
+ m = fromnumeric.ravel(self._mask)
try:
if m[0]:
return masked
@@ -1428,7 +1428,7 @@ def allclose (a, b, fill_value=1, rtol=1.e-5, atol=1.e-8):
x = filled(array(d1, copy=0, mask=m), fill_value).astype(float)
y = filled(array(d2, copy=0, mask=m), 1).astype(float)
d = umath.less_equal(umath.absolute(x-y), atol + rtol * umath.absolute(y))
- return oldnumeric.alltrue(oldnumeric.ravel(d))
+ return fromnumeric.alltrue(fromnumeric.ravel(d))
def allequal (a, b, fill_value=1):
"""
@@ -1440,13 +1440,13 @@ def allequal (a, b, fill_value=1):
x = filled(a)
y = filled(b)
d = umath.equal(x, y)
- return oldnumeric.alltrue(oldnumeric.ravel(d))
+ return fromnumeric.alltrue(fromnumeric.ravel(d))
elif fill_value:
x = filled(a)
y = filled(b)
d = umath.equal(x, y)
dm = array(d, mask=m, copy=0)
- return oldnumeric.alltrue(oldnumeric.ravel(filled(dm, 1)))
+ return fromnumeric.alltrue(fromnumeric.ravel(filled(dm, 1)))
else:
return 0
@@ -1514,8 +1514,8 @@ def resize (a, new_shape):
The original array's total size can be any size."""
m = getmask(a)
if m is not nomask:
- m = oldnumeric.resize(m, new_shape)
- result = array(oldnumeric.resize(filled(a), new_shape), mask=m)
+ m = fromnumeric.resize(m, new_shape)
+ result = array(fromnumeric.resize(filled(a), new_shape), mask=m)
result.set_fill_value(get_fill_value(a))
return result
@@ -1530,8 +1530,8 @@ def repeat(a, repeats, axis=0):
m = getmask(a)
if m is not nomask:
- m = oldnumeric.repeat(m, repeats, axis)
- d = oldnumeric.repeat(af, repeats, axis)
+ m = fromnumeric.repeat(m, repeats, axis)
+ d = fromnumeric.repeat(af, repeats, axis)
result = masked_array(d, m)
result.set_fill_value(get_fill_value(a))
return result
@@ -1624,7 +1624,7 @@ def average (a, axis=0, weights=None, returned = 0):
else:
if weights is None:
n = add.reduce(a.ravel())
- w = oldnumeric.choose(mask, (1.0, 0.0)).ravel()
+ w = fromnumeric.choose(mask, (1.0, 0.0)).ravel()
d = umath.add.reduce(w)
del w
else:
@@ -1814,7 +1814,7 @@ def reshape (a, *newshape):
def ravel (a):
"a as one-dimensional, may share data and mask"
m = getmask(a)
- d = oldnumeric.ravel(filled(a))
+ d = fromnumeric.ravel(filled(a))
if m is nomask:
return masked_array(d)
else:
@@ -2053,19 +2053,19 @@ def sort (x, axis = -1, fill_value=None):
if fill_value is None:
fill_value = default_fill_value (x)
d = filled(x, fill_value)
- s = oldnumeric.sort(d, axis)
+ s = fromnumeric.sort(d, axis)
if getmask(x) is nomask:
return masked_array(s)
return masked_values(s, fill_value, copy=0)
def diagonal(a, k = 0, axis1=0, axis2=1):
"""diagonal(a,k=0,axis1=0, axis2=1) = the k'th diagonal of a"""
- d = oldnumeric.diagonal(filled(a), k, axis1, axis2)
+ d = fromnumeric.diagonal(filled(a), k, axis1, axis2)
m = getmask(a)
if m is nomask:
return masked_array(d, m)
else:
- return masked_array(d, oldnumeric.diagonal(m, k, axis1, axis2))
+ return masked_array(d, fromnumeric.diagonal(m, k, axis1, axis2))
def trace (a, offset=0, axis1=0, axis2=1, dtype=None):
"""trace(a,offset=0, axis1=0, axis2=1) returns the sum along diagonals
@@ -2080,7 +2080,7 @@ def argsort (x, axis = -1, fill_value=None):
Returns a numpy array.
"""
d = filled(x, fill_value)
- return oldnumeric.argsort(d, axis)
+ return fromnumeric.argsort(d, axis)
def argmin (x, axis = -1, fill_value=None):
"""Treating masked values as if they have the value fill_value,
@@ -2090,7 +2090,7 @@ def argmin (x, axis = -1, fill_value=None):
Otherwise, returns a scalar index.
"""
d = filled(x, fill_value)
- return oldnumeric.argmin(d, axis)
+ return fromnumeric.argmin(d, axis)
def argmax (x, axis = -1, fill_value=None):
"""Treating masked values as if they have the value fill_value,
@@ -2106,7 +2106,7 @@ def argmax (x, axis = -1, fill_value=None):
except:
pass
d = filled(x, fill_value)
- return oldnumeric.argmax(d, axis)
+ return fromnumeric.argmax(d, axis)
def fromfunction (f, s):
"""apply f to s to create array as in umath."""
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index 973307220..5673d8488 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -537,6 +537,6 @@ nan = NaN = NAN
False_ = bool_(False)
True_ = bool_(True)
-import oldnumeric
-from oldnumeric import *
-extend_all(oldnumeric)
+import fromnumeric
+from fromnumeric import *
+extend_all(fromnumeric)
diff --git a/numpy/core/numerictypes.py b/numpy/core/numerictypes.py
index 32e0d1626..ae9dc0a27 100644
--- a/numpy/core/numerictypes.py
+++ b/numpy/core/numerictypes.py
@@ -77,7 +77,7 @@ $Id: numerictypes.py,v 1.17 2005/09/09 22:20:06 teoliphant Exp $
# we add more at the bottom
__all__ = ['typeDict', 'typeNA', 'sctypes', 'ScalarType', 'obj2sctype', 'cast', 'nbytes',
- 'sctype2char', 'maximum_sctype', 'issctype']
+ 'sctype2char', 'maximum_sctype', 'issctype', 'typecodes']
from multiarray import typeinfo, ndarray, array, empty
import types as _types
@@ -421,3 +421,12 @@ for key in allTypes:
__all__.append(key)
del key
+
+typecodes = {'Character':'S1',
+ 'Integer':'bhilqp',
+ 'UnsignedInteger':'BHILQP',
+ 'Float':'fdg',
+ 'Complex':'FDG',
+ 'AllInteger':'bBhHiIlLqQpP',
+ 'AllFloat':'fdgFDG',
+ 'All':'?bhilqpBHILQPfdgFDGSUVO'}
diff --git a/numpy/core/tests/test_ma.py b/numpy/core/tests/test_ma.py
index fe8864e91..afdda90de 100644
--- a/numpy/core/tests/test_ma.py
+++ b/numpy/core/tests/test_ma.py
@@ -668,7 +668,7 @@ class test_ufuncs(ScipyTestCase):
try:
uf = getattr(umath, f)
except AttributeError:
- uf = getattr(oldnumeric, f)
+ uf = getattr(fromnumeric, f)
mf = getattr(numpy.ma, f)
args = self.d[:uf.nin]
ur = uf(*args)
diff --git a/numpy/core/tests/test_oldnumeric.py b/numpy/core/tests/test_oldnumeric.py
deleted file mode 100644
index 0173bdcca..000000000
--- a/numpy/core/tests/test_oldnumeric.py
+++ /dev/null
@@ -1,29 +0,0 @@
-from numpy.testing import *
-
-from numpy import array, ndarray, arange, argmax
-from numpy.core.oldnumeric import put
-
-class test_put(ScipyTestCase):
- def check_bug_r2089(self, level=1):
- a = array([0,0,0])
- put(a,[1],[1.2])
- assert_array_equal(a,[0,1,0])
- put(a,[1],array([2.2]))
- assert_array_equal(a,[0,2,0])
-
-class test_wrapit(ScipyTestCase):
- def check_array_subclass(self, level=1):
- class subarray(ndarray):
- def get_argmax(self):
- raise AttributeError
- argmax = property(get_argmax)
- a = subarray([3], int, arange(3))
- assert_equal(argmax(a), 2)
- b = subarray([3, 3], int, arange(9))
- bmax = argmax(b)
- assert_array_equal(bmax, [2,2,2])
- assert_equal(type(bmax), subarray)
-
-
-if __name__ == "__main__":
- ScipyTest().run()
diff --git a/numpy/lib/convertcode.py b/numpy/lib/convertcode.py
index d45bd2fe3..b58e56b78 100644
--- a/numpy/lib/convertcode.py
+++ b/numpy/lib/convertcode.py
@@ -91,12 +91,12 @@ def replaceother(astr):
import datetime
def fromstr(filestr):
filestr = replacetypechars(filestr)
- filestr, fromall1 = changeimports(filestr, 'Numeric', 'numpy')
+ filestr, fromall1 = changeimports(filestr, 'Numeric', 'numpy.oldnumeric')
filestr, fromall1 = changeimports(filestr, 'multiarray',
'numpy.core.multiarray')
filestr, fromall1 = changeimports(filestr, 'umath',
'numpy.core.umath')
- filestr, fromall1 = changeimports(filestr, 'Precision', 'numpy')
+ filestr, fromall1 = changeimports(filestr, 'Precision', 'numpy.oldnumeric')
filestr, fromall2 = changeimports(filestr, 'numerix', 'numpy')
filestr, fromall3 = changeimports(filestr, 'scipy_base', 'numpy')
filestr, fromall3 = changeimports(filestr, 'MLab', 'numpy.lib.mlab')
diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py
index 934f7da33..778aa1e09 100644
--- a/numpy/lib/function_base.py
+++ b/numpy/lib/function_base.py
@@ -17,8 +17,8 @@ from numpy.core.numeric import ones, zeros, arange, concatenate, array, \
from numpy.core.numeric import ScalarType, dot, where, newaxis
from numpy.core.umath import pi, multiply, add, arctan2, \
frompyfunc, isnan, cos, less_equal, sqrt, sin, mod, exp
-from numpy.core.oldnumeric import ravel, nonzero, choose, \
- typecodes, sort
+from numpy.core.fromnumeric import ravel, nonzero, choose, sort
+from numpy.core.numerictypes import typecodes
from numpy.lib.shape_base import atleast_1d
from numpy.lib.twodim_base import diag
from _compiled_base import digitize, bincount, _insert, add_docstring
@@ -160,7 +160,7 @@ def asarray_chkfinite(a):
"""Like asarray, but check that no NaNs or Infs are present.
"""
a = asarray(a)
- if (a.dtype.char in _nx.typecodes['AllFloat']) \
+ if (a.dtype.char in typecodes['AllFloat']) \
and (_nx.isnan(a).any() or _nx.isinf(a).any()):
raise ValueError, "array must not contain infs or NaNs"
return a
diff --git a/numpy/lib/machar.py b/numpy/lib/machar.py
index 4c2282454..443fef83b 100644
--- a/numpy/lib/machar.py
+++ b/numpy/lib/machar.py
@@ -7,7 +7,7 @@ floating-point arithmetic system
__all__ = ['MachAr']
-from numpy.core.oldnumeric import any
+from numpy.core.fromnumeric import any
# Need to speed this up...especially for longfloat
diff --git a/numpy/lib/mlab.py b/numpy/lib/mlab.py
index cb634b826..e26761117 100644
--- a/numpy/lib/mlab.py
+++ b/numpy/lib/mlab.py
@@ -3,8 +3,7 @@
from numpy.core.numeric import *
from twodim_base import eye, tri, diag, fliplr, flipud, rot90, tril, triu
-from numpy.core.oldnumeric import amax as max
-from numpy.core.oldnumeric import amin as min
+from numpy.core.fromnumeric import amax as max, amin as min
from function_base import msort, median, trapz, diff, cov, corrcoef, \
kaiser, blackman, bartlett, hanning, hamming, sinc, angle
from numpy.core.oldnumeric import cumsum, ptp, mean, std, prod, cumprod, \
diff --git a/numpy/lib/shape_base.py b/numpy/lib/shape_base.py
index aae57f984..f313028f1 100644
--- a/numpy/lib/shape_base.py
+++ b/numpy/lib/shape_base.py
@@ -6,7 +6,7 @@ __all__ = ['atleast_1d','atleast_2d','atleast_3d','vstack','hstack',
import numpy.core.numeric as _nx
from numpy.core.numeric import asarray, zeros, newaxis, outer, \
concatenate, isscalar, array, asanyarray
-from numpy.core.oldnumeric import product, reshape
+from numpy.core.fromnumeric import product, reshape
def apply_along_axis(func1d,axis,arr,*args):
""" Execute func1d(arr[i],*args) where func1d takes 1-D arrays
diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py
new file mode 100644
index 000000000..ca9d32044
--- /dev/null
+++ b/numpy/oldnumeric/compat.py
@@ -0,0 +1,171 @@
+# Compatibility module containing deprecated names
+
+__all__ = ['NewAxis',
+ 'UFuncType', 'UfuncType', 'ArrayType', 'arraytype',
+ 'LittleEndian', 'Bool',
+ 'Character', 'UnsignedInt8', 'UnsignedInt16', 'UnsignedInt', 'UInt',
+ 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger',
+ # UnsignedInt64 and Unsigned128 added below if possible
+ # same for Int64 and Int128, Float128, and Complex128
+ 'Int8', 'Int16', 'Int32',
+ 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex',
+ 'PyObject', 'Float32', 'Float64', 'Float16', 'Float8',
+ 'Complex32', 'Complex64', 'Complex8', 'Complex16',
+ 'sarray', 'arrayrange', 'cross_correlate',
+ 'matrixmultiply', 'outerproduct', 'innerproduct',
+ 'cross_product', 'array_constructor',
+ 'DumpArray', 'LoadArray', 'multiarray', 'divide_safe',
+ # from cPickle
+ 'dump', 'dumps'
+ ]
+
+import numpy.core.multiarray as mu
+import numpy.core.umath as um
+import numpy.core.numerictypes as nt
+from numpy.core.numeric import asarray, array, asanyarray, \
+ correlate, outer, concatenate, cross
+from numpy.core.umath import sign, absolute, multiply
+import numpy.core.numeric as _nx
+import sys
+_dt_ = nt.sctype2char
+
+import types
+
+from cPickle import dump, dumps
+
+multiarray = mu
+
+def sarray(a, dtype=None, copy=False):
+ return array(a, dtype, copy)
+
+#Use this to add a new axis to an array
+#compatibility only
+NewAxis = None
+
+#deprecated
+UFuncType = type(um.sin)
+UfuncType = type(um.sin)
+ArrayType = mu.ndarray
+arraytype = mu.ndarray
+
+LittleEndian = (sys.byteorder == 'little')
+
+# backward compatible names from old Precision.py
+
+Character = 'S1'
+UnsignedInt8 = _dt_(nt.uint8)
+UInt8 = UnsignedInt8
+UnsignedInt16 = _dt_(nt.uint16)
+UInt16 = UnsignedInt16
+UnsignedInt32 = _dt_(nt.uint32)
+UInt32 = UnsignedInt32
+UnsignedInt = _dt_(nt.uint)
+UInt = UnsignedInt
+
+try:
+ UnsignedInt64 = _dt_(nt.uint64)
+except AttributeError:
+ pass
+else:
+ UInt64 = UnsignedInt64
+ __all__ += ['UnsignedInt64', 'UInt64']
+try:
+ UnsignedInt128 = _dt_(nt.uint128)
+except AttributeError:
+ pass
+else:
+ UInt128 = UnsignedInt128
+ __all__ += ['UnsignedInt128','UInt128']
+
+Int8 = _dt_(nt.int8)
+Int16 = _dt_(nt.int16)
+Int32 = _dt_(nt.int32)
+
+try:
+ Int64 = _dt_(nt.int64)
+except AttributeError:
+ pass
+else:
+ __all__ += ['Int64']
+
+try:
+ Int128 = _dt_(nt.int128)
+except AttributeError:
+ pass
+else:
+ __all__ += ['Int128']
+
+Bool = _dt_(bool)
+Int0 = _dt_(int)
+Int = _dt_(int)
+Float0 = _dt_(float)
+Float = _dt_(float)
+Complex0 = _dt_(complex)
+Complex = _dt_(complex)
+PyObject = _dt_(nt.object_)
+Float32 = _dt_(nt.float32)
+Float64 = _dt_(nt.float64)
+
+Float16='f'
+Float8='f'
+UnsignedInteger='L'
+Complex8='F'
+Complex16='F'
+
+try:
+ Float128 = _dt_(nt.float128)
+except AttributeError:
+ pass
+else:
+ __all__ += ['Float128']
+
+Complex32 = _dt_(nt.complex64)
+Complex64 = _dt_(nt.complex128)
+
+try:
+ Complex128 = _dt_(nt.complex256)
+except AttributeError:
+ pass
+else:
+ __all__ += ['Complex128']
+
+def _deprecate(func, oldname, newname):
+ import warnings
+ def newfunc(*args,**kwds):
+ warnings.warn("%s is deprecated, use %s" % (oldname, newname),
+ DeprecationWarning)
+ return func(*args, **kwds)
+ return newfunc
+
+# backward compatibility
+arrayrange = _deprecate(mu.arange, 'arrayrange', 'arange')
+cross_correlate = _deprecate(correlate, 'cross_correlate', 'correlate')
+cross_product = _deprecate(cross, 'cross_product', 'cross')
+divide_safe = _deprecate(um.divide, 'divide_safe', 'divide')
+
+# deprecated names
+matrixmultiply = _deprecate(mu.dot, 'matrixmultiply', 'dot')
+outerproduct = _deprecate(outer, 'outerproduct', 'outer')
+innerproduct = _deprecate(mu.inner, 'innerproduct', 'inner')
+
+
+
+def DumpArray(m, fp):
+ m.dump(fp)
+
+def LoadArray(fp):
+ import cPickle
+ return cPickle.load(fp)
+
+def array_constructor(shape, typecode, thestr, Endian=LittleEndian):
+ if typecode == "O":
+ x = array(thestr, "O")
+ else:
+ x = mu.fromstring(thestr, typecode)
+ x.shape = shape
+ if LittleEndian != Endian:
+ return x.byteswap(TRUE)
+ else:
+ return x
+
+
diff --git a/numpy/oldnumeric/tests/test_oldnumeric.py b/numpy/oldnumeric/tests/test_oldnumeric.py
new file mode 100644
index 000000000..14d5dfd84
--- /dev/null
+++ b/numpy/oldnumeric/tests/test_oldnumeric.py
@@ -0,0 +1,86 @@
+from numpy.testing import *
+
+from numpy import array
+from numpy.oldnumeric import *
+from numpy.core.numeric import float32, float64, complex64, complex128, int8, \
+ int16, int32, int64, uint, uint8, uint16, uint32, uint64
+
+class test_oldtypes(NumPyTestCase):
+ def check_oldtypes(self, level=1):
+ a1 = array([0,1,0], Float)
+ a2 = array([0,1,0], float)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Float8)
+ a2 = array([0,1,0], float)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Float16)
+ a2 = array([0,1,0], float)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Float32)
+ a2 = array([0,1,0], float32)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Float64)
+ a2 = array([0,1,0], float64)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Complex)
+ a2 = array([0,1,0], complex)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Complex8)
+ a2 = array([0,1,0], complex)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Complex16)
+ a2 = array([0,1,0], complex)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Complex32)
+ a2 = array([0,1,0], complex64)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Complex64)
+ a2 = array([0,1,0], complex128)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Int)
+ a2 = array([0,1,0], int)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Int8)
+ a2 = array([0,1,0], int8)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Int16)
+ a2 = array([0,1,0], int16)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Int32)
+ a2 = array([0,1,0], int32)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], Int64)
+ a2 = array([0,1,0], int64)
+ assert_array_equal(a1, a2)
+ a1 = array([0,1,0], UnsignedInt)
+ a2 = array([0,1,0], UnsignedInteger)
+ a3 = array([0,1,0], uint)
+ assert_array_equal(a1, a3)
+ assert_array_equal(a2, a3)
+ a1 = array([0,1,0], UInt8)
+ a2 = array([0,1,0], UnsignedInt8)
+ a3 = array([0,1,0], uint8)
+ assert_array_equal(a1, a3)
+ assert_array_equal(a2, a3)
+ a1 = array([0,1,0], UInt16)
+ a2 = array([0,1,0], UnsignedInt16)
+ a3 = array([0,1,0], uint16)
+ assert_array_equal(a1, a3)
+ assert_array_equal(a2, a3)
+ a1 = array([0,1,0], UInt32)
+ a2 = array([0,1,0], UnsignedInt32)
+ a3 = array([0,1,0], uint32)
+ assert_array_equal(a1, a3)
+ assert_array_equal(a2, a3)
+ a1 = array([0,1,0], UInt64)
+ a2 = array([0,1,0], UnsignedInt64)
+ a3 = array([0,1,0], uint64)
+ assert_array_equal(a1, a3)
+ assert_array_equal(a2, a3)
+ a1 = array([0,1,0], Bool)
+ a2 = array([0,1,0], bool)
+ assert_array_equal(a1, a2)
+
+
+if __name__ == "__main__":
+ NumPyTest().run()
diff --git a/numpy/random/oldrngstats.py b/numpy/random/oldrngstats.py
index b795eee09..60248247e 100644
--- a/numpy/random/oldrngstats.py
+++ b/numpy/random/oldrngstats.py
@@ -1,7 +1,7 @@
__all__ = ['average', 'histogram', 'standardDeviation', 'variance']
-import numpy as Numeric
+import numpy.oldnumeric as Numeric
def average(data):
data = Numeric.array(data)
diff --git a/numpy/setup.py b/numpy/setup.py
index 621838aba..1f8f6e2b5 100644
--- a/numpy/setup.py
+++ b/numpy/setup.py
@@ -8,6 +8,7 @@ def configuration(parent_package='',top_path=None):
config.add_subpackage('f2py')
config.add_subpackage('core')
config.add_subpackage('lib')
+ config.add_subpackage('oldnumeric')
config.add_subpackage('dft')
config.add_subpackage('linalg')
config.add_subpackage('random')