summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-08-04 23:32:12 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-08-04 23:32:12 +0000
commitf1cca04886d4f63f7b1ed5b382986af3a9ee6a61 (patch)
tree053f566b31cb6edc24a41b800ec7f2972c4bca40
parent8f26568de7cc97ac0dcedfd5061e08bb54770b61 (diff)
downloadpython-numpy-f1cca04886d4f63f7b1ed5b382986af3a9ee6a61.tar.gz
python-numpy-f1cca04886d4f63f7b1ed5b382986af3a9ee6a61.tar.bz2
python-numpy-f1cca04886d4f63f7b1ed5b382986af3a9ee6a61.zip
Many name-changes in oldnumeric. This may break some numpy code that was using the oldnumeric interface.
-rw-r--r--numpy/__init__.py6
-rw-r--r--numpy/dual.py2
-rw-r--r--numpy/fft/__init__.py (renamed from numpy/dft/__init__.py)0
-rw-r--r--numpy/fft/fftpack.c (renamed from numpy/dft/fftpack.c)0
-rw-r--r--numpy/fft/fftpack.h (renamed from numpy/dft/fftpack.h)0
-rw-r--r--numpy/fft/fftpack.py (renamed from numpy/dft/fftpack.py)0
-rw-r--r--numpy/fft/fftpack_litemodule.c (renamed from numpy/dft/fftpack_litemodule.c)0
-rw-r--r--numpy/fft/helper.py (renamed from numpy/dft/helper.py)0
-rw-r--r--numpy/fft/info.py (renamed from numpy/dft/info.py)0
-rw-r--r--numpy/fft/old.py (renamed from numpy/dft/old.py)0
-rw-r--r--numpy/fft/setup.py (renamed from numpy/dft/setup.py)2
-rw-r--r--numpy/fft/tests/test_helper.py (renamed from numpy/dft/tests/test_helper.py)2
-rw-r--r--numpy/lib/convertnumericA.py30
-rw-r--r--numpy/lib/convertnumericB.py4
-rw-r--r--numpy/lib/mlab.py18
-rw-r--r--numpy/lib/user_array.py (renamed from numpy/lib/UserArray.py)8
-rw-r--r--numpy/oldnumeric/__init__.py22
-rw-r--r--numpy/oldnumeric/compat.py2
-rw-r--r--numpy/oldnumeric/linear_algebra.py (renamed from numpy/linalg/old.py)2
-rw-r--r--numpy/oldnumeric/mlab.py72
-rw-r--r--numpy/oldnumeric/olddefaults.py39
-rw-r--r--numpy/oldnumeric/random_array.py (renamed from numpy/random/old.py)1
-rw-r--r--numpy/oldnumeric/rng.py (renamed from numpy/random/oldrng.py)3
-rw-r--r--numpy/oldnumeric/rng_stats.py (renamed from numpy/random/oldrngstats.py)0
-rw-r--r--numpy/setup.py1
25 files changed, 125 insertions, 89 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py
index d83ff5172..42f987b24 100644
--- a/numpy/__init__.py
+++ b/numpy/__init__.py
@@ -37,14 +37,14 @@ else:
import lib
from lib import *
import linalg
- import dft
+ import fft
import random
__all__ = ['__version__', 'pkgload', 'PackageLoader',
'ScipyTest', 'NumpyTest', 'show_config']
__all__ += core.__all__
__all__ += lib.__all__
- __all__ += ['linalg', 'dft', 'random']
+ __all__ += ['linalg', 'fft', 'random']
if __doc__ is not None:
__doc__ += """
@@ -57,7 +57,7 @@ lib --- Basic functions used by several sub-packages and useful
to have in the main name-space.
random --- Core Random Tools
linalg --- Core Linear Algebra Tools
-dft --- Core FFT routines
+fft --- Core FFT routines
testing --- Scipy testing tools
These packages require explicit import
diff --git a/numpy/dual.py b/numpy/dual.py
index 8e05ba3b8..c47f8f820 100644
--- a/numpy/dual.py
+++ b/numpy/dual.py
@@ -8,7 +8,7 @@ __all__ = ['fft','ifft','fftn','ifftn','fft2','ifft2',
'eigh','eigvalsh','lstsq', 'pinv','cholesky','i0']
import numpy.linalg as linpkg
-import numpy.dft as fftpkg
+import numpy.fft as fftpkg
from numpy.lib import i0
import sys
diff --git a/numpy/dft/__init__.py b/numpy/fft/__init__.py
index 0c5a7f2ed..0c5a7f2ed 100644
--- a/numpy/dft/__init__.py
+++ b/numpy/fft/__init__.py
diff --git a/numpy/dft/fftpack.c b/numpy/fft/fftpack.c
index 3e5e7d2ed..3e5e7d2ed 100644
--- a/numpy/dft/fftpack.c
+++ b/numpy/fft/fftpack.c
diff --git a/numpy/dft/fftpack.h b/numpy/fft/fftpack.h
index d134784a2..d134784a2 100644
--- a/numpy/dft/fftpack.h
+++ b/numpy/fft/fftpack.h
diff --git a/numpy/dft/fftpack.py b/numpy/fft/fftpack.py
index 1cb24f2b7..1cb24f2b7 100644
--- a/numpy/dft/fftpack.py
+++ b/numpy/fft/fftpack.py
diff --git a/numpy/dft/fftpack_litemodule.c b/numpy/fft/fftpack_litemodule.c
index f6d9aaf6b..f6d9aaf6b 100644
--- a/numpy/dft/fftpack_litemodule.c
+++ b/numpy/fft/fftpack_litemodule.c
diff --git a/numpy/dft/helper.py b/numpy/fft/helper.py
index 4e1da2abd..4e1da2abd 100644
--- a/numpy/dft/helper.py
+++ b/numpy/fft/helper.py
diff --git a/numpy/dft/info.py b/numpy/fft/info.py
index 4aa9b7d2c..4aa9b7d2c 100644
--- a/numpy/dft/info.py
+++ b/numpy/fft/info.py
diff --git a/numpy/dft/old.py b/numpy/fft/old.py
index 86723af95..86723af95 100644
--- a/numpy/dft/old.py
+++ b/numpy/fft/old.py
diff --git a/numpy/dft/setup.py b/numpy/fft/setup.py
index 2ec72619f..4d1de069d 100644
--- a/numpy/dft/setup.py
+++ b/numpy/fft/setup.py
@@ -3,7 +3,7 @@ from os.path import join
def configuration(parent_package='',top_path=None):
from numpy.distutils.misc_util import Configuration
- config = Configuration('dft',parent_package,top_path)
+ config = Configuration('fft',parent_package,top_path)
config.add_data_dir('tests')
diff --git a/numpy/dft/tests/test_helper.py b/numpy/fft/tests/test_helper.py
index 13f194c83..3d02c01df 100644
--- a/numpy/dft/tests/test_helper.py
+++ b/numpy/fft/tests/test_helper.py
@@ -6,7 +6,7 @@
import sys
from numpy.testing import *
set_package_path()
-from numpy.dft import fftshift,ifftshift,fftfreq
+from numpy.fft import fftshift,ifftshift,fftfreq
del sys.path[0]
from numpy import pi
diff --git a/numpy/lib/convertnumericA.py b/numpy/lib/convertnumericA.py
index 446d81e3d..ad1daa329 100644
--- a/numpy/lib/convertnumericA.py
+++ b/numpy/lib/convertnumericA.py
@@ -73,21 +73,21 @@ import datetime
def fromstr(filestr):
#filestr = replacetypechars(filestr)
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.oldnumeric')
- filestr, fromall2 = changeimports(filestr, 'numerix', 'numpy')
- filestr, fromall3 = changeimports(filestr, 'scipy_base', 'numpy')
- filestr, fromall3 = changeimports(filestr, 'MLab', 'numpy.lib.mlab')
- filestr, fromall3 = changeimports(filestr, 'LinearAlgebra',
- 'numpy.linalg.old')
- filestr, fromall3 = changeimports(filestr, 'RNG', 'numpy.random.oldrng')
- filestr, fromall3 = changeimports(filestr, 'RNG.Statistics', 'numpy.random.oldrngstats')
- filestr, fromall3 = changeimports(filestr, 'RandomArray', 'numpy.random.oldrandomarray')
- filestr, fromall3 = changeimports(filestr, 'FFT', 'numpy.dft.old')
- filestr, fromall3 = changeimports(filestr, 'MA', 'numpy.core.ma')
+ filestr, fromall1 = changeimports(filestr, 'multiarray','numpy.oldnumeric')
+ filestr, fromall1 = changeimports(filestr, 'umath', 'numpy.oldnumeric')
+ filestr, fromall1 = changeimports(filestr, 'Precision', 'numpy.oldnumeric.precision')
+ filestr, fromall1 = changeimports(filestr, 'UserArray', 'numpy.oldnumeric.user_array')
+ filestr, fromall1 = changeimports(filestr, 'ArrayPrinter', 'numpy.oldnumeric.array_printer')
+ filestr, fromall2 = changeimports(filestr, 'numerix', 'numpy.oldnumeric')
+ filestr, fromall3 = changeimports(filestr, 'scipy_base', 'numpy.oldnumeric')
+ filestr, fromall3 = changeimports(filestr, 'Matrix', 'numpy.oldnumeric.matrix')
+ filestr, fromall3 = changeimports(filestr, 'MLab', 'numpy.oldnumeric.mlab')
+ filestr, fromall3 = changeimports(filestr, 'LinearAlgebra', 'numpy.oldnumeric.linear_algebra')
+ filestr, fromall3 = changeimports(filestr, 'RNG', 'numpy.oldnumeric.rng')
+ filestr, fromall3 = changeimports(filestr, 'RNG.Statistics', 'numpy.oldnumeric.rng_stats')
+ filestr, fromall3 = changeimports(filestr, 'RandomArray', 'numpy.oldnumeric.random_array')
+ filestr, fromall3 = changeimports(filestr, 'FFT', 'numpy.oldnumeric.fft')
+ filestr, fromall3 = changeimports(filestr, 'MA', 'numpy.oldnumeric.ma')
fromall = fromall1 or fromall2 or fromall3
filestr = replaceattr(filestr)
filestr = replaceother(filestr)
diff --git a/numpy/lib/convertnumericB.py b/numpy/lib/convertnumericB.py
index cd26723a3..36bdd8572 100644
--- a/numpy/lib/convertnumericB.py
+++ b/numpy/lib/convertnumericB.py
@@ -56,7 +56,7 @@ def changeimports(fstr, name, newname):
return fstr, fromall
def replaceattr(astr):
- astr = astr.replace("matrixmultiply","dot")
+ astr = astr.replace("matrixmultiply","dot")
return astr
def replaceother(astr):
@@ -76,7 +76,7 @@ def fromstr(filestr):
filestr, fromall3 = changeimports(filestr, 'RNG', 'numpy.random.oldrng')
filestr, fromall3 = changeimports(filestr, 'RNG.Statistics', 'numpy.random.oldrngstats')
filestr, fromall3 = changeimports(filestr, 'RandomArray', 'numpy.random.oldrandomarray')
- filestr, fromall3 = changeimports(filestr, 'FFT', 'numpy.dft.old')
+ filestr, fromall3 = changeimports(filestr, 'FFT', 'numpy.fft.old')
filestr, fromall3 = changeimports(filestr, 'MA', 'numpy.core.ma')
fromall = fromall1 or fromall2 or fromall3
filestr = replaceattr(filestr)
diff --git a/numpy/lib/mlab.py b/numpy/lib/mlab.py
deleted file mode 100644
index fd66ecd70..000000000
--- a/numpy/lib/mlab.py
+++ /dev/null
@@ -1,18 +0,0 @@
-# This module is for compatibility only. All functions are defined elsewhere.
-
-from numpy.core.numeric import *
-
-from twodim_base import diag, fliplr, flipud, rot90, tril, triu
-
-# use old defaults
-from numpy.oldnumeric import eye, tri
-
-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.fromnumeric import cumsum, ptp, mean, std, prod, cumprod, \
- squeeze
-from polynomial import roots
-
-from numpy.random import rand, randn
-from numpy.dual import eig, svd
diff --git a/numpy/lib/UserArray.py b/numpy/lib/user_array.py
index 0d74450d5..d20593f45 100644
--- a/numpy/lib/UserArray.py
+++ b/numpy/lib/user_array.py
@@ -1,5 +1,5 @@
"""
-Standard container-class for easy backward compatibility with Numeric.
+Standard container-class for easy multiple-inheritance.
Try to inherit from the ndarray instead of using this class as this is not
complete.
"""
@@ -9,7 +9,7 @@ from numpy.core import array, asarray, absolute, add, subtract, multiply, \
bitwise_or, bitwise_xor, invert, less, less_equal, not_equal, equal, \
greater, greater_equal, shape, reshape, arange, sin, sqrt, transpose
-class UserArray(object):
+class container(object):
def __init__(self, data, dtype=None, copy=True):
self.array = array(data, dtype, copy=copy)
@@ -196,12 +196,12 @@ class UserArray(object):
return self.array.__getattribute__(attr)
#############################################################
-# Test of class UserArray
+# Test of class container
#############################################################
if __name__ == '__main__':
temp=reshape(arange(10000),(100,100))
- ua=UserArray(temp)
+ ua=container(temp)
# new object created begin test
print dir(ua)
print shape(ua),ua.shape # I have changed Numeric.py
diff --git a/numpy/oldnumeric/__init__.py b/numpy/oldnumeric/__init__.py
index 67874f814..14895910f 100644
--- a/numpy/oldnumeric/__init__.py
+++ b/numpy/oldnumeric/__init__.py
@@ -1,33 +1,25 @@
+# Don't add these to the __all__ variable
from numpy import *
+
+# Add these
from compat import *
from olddefaults import *
-from typeconv import *
from functions import *
-import numpy
import compat
import olddefaults
-import typeconv
import functions
+import numpy
__version__ = numpy.__version__
+del numpy
__all__ = ['__version__']
-__all__ += numpy.__all__
__all__ += compat.__all__
-__all__ += typeconv.__all__
-for name in olddefaults.__all__:
- if name not in __all__:
- __all__.append(name)
-
-for name in functions.__all__:
- if name not in __all__:
- __all__.apend(name)
+__all__ += olddefaults.__all__
+__all__ += functions.__all__
-del name
-del numpy
del compat
del olddefaults
del functions
-del typeconv
diff --git a/numpy/oldnumeric/compat.py b/numpy/oldnumeric/compat.py
index 3c8cf9b70..fa6ea94c4 100644
--- a/numpy/oldnumeric/compat.py
+++ b/numpy/oldnumeric/compat.py
@@ -54,7 +54,7 @@ LittleEndian = (sys.byteorder == 'little')
# backward compatible names from old Precision.py
-Character = 'S1'
+Character = 'c'
UnsignedInt8 = _dt_(nt.uint8)
UInt8 = UnsignedInt8
UnsignedInt16 = _dt_(nt.uint16)
diff --git a/numpy/linalg/old.py b/numpy/oldnumeric/linear_algebra.py
index 2ac1e9d48..90d6f7138 100644
--- a/numpy/linalg/old.py
+++ b/numpy/oldnumeric/linear_algebra.py
@@ -16,7 +16,7 @@ __all__ = ['LinAlgError', 'solve_linear_equations',
]
from numpy.core import transpose
-import linalg
+import numpy.linalg as linalg
# Linear equations
diff --git a/numpy/oldnumeric/mlab.py b/numpy/oldnumeric/mlab.py
new file mode 100644
index 000000000..409238e57
--- /dev/null
+++ b/numpy/oldnumeric/mlab.py
@@ -0,0 +1,72 @@
+# This module is for compatibility only. All functions are defined elsewhere.
+
+from numpy.oldnumeric import *
+
+__all__ = numpy.oldnumeric.__all__
+
+__all__ += ['rand', 'tril', 'trapz', 'hanning', 'rot90', 'triu', 'diff', 'angle', 'roots', 'ptp', 'kaiser', 'randn', 'cumprod', 'diag', 'msort', 'LinearAlgebra', 'RandomArray', 'prod', 'std', 'hamming', 'flipud', 'max', 'blackman', 'corrcoef', 'bartlett', 'eye', 'squeeze', 'sinc', 'tri', 'cov', 'svd', 'min', 'median', 'fliplr', 'eig', 'mean']
+
+import linear_algebra as LinearAlgebra
+import random_array as RandomArray
+from numpy import tril, trapz as _Ntrapz, hanning, rot90, triu, diff, \
+ angle, roots, ptp as _Nptp, kaiser, cumprod as _Ncumprod, \
+ diag, msort, prod as _Nprod, std as _Nstd, hamming, flipud, \
+ amax as _Nmax, amin as _Nmin, blackman, bartlett, corrcoef as _Ncorrcoef,\
+ cov as _Ncov, squeeze, sinc, median, fliplr, mean as _Nmean
+
+from numpy.linalg import eig, svd
+from numpy.random import rand, randn
+
+from typeconv import oldtype2dtype as o2d
+
+def eye(N, M=None, k=0, typecode=None):
+ """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones,
+ and everything else is zeros.
+ """
+ dtype = o2d[typecode]
+ if M is None: M = N
+ m = nn.equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k)
+ if m.dtype != dtype:
+ return m.astype(dtype)
+
+def tri(N, M=None, k=0, typecode=None):
+ """ returns a N-by-M array where all the diagonals starting from
+ lower left corner up to the k-th are all ones.
+ """
+ dtype = o2d[typecode]
+ if M is None: M = N
+ m = nn.greater_equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k)
+ if m.dtype != dtype:
+ return m.astype(dtype)
+
+def trapz(y, x=None, axis=-1):
+ return _Ntrapz(y, x, axis=axis)
+
+def ptp(x, axis=0):
+ return _Nptp(x, axis)
+
+def cumprod(x, axis=0):
+ return _Ncumprod(x, axis)
+
+def max(x, axis=0):
+ return _Nmax(x, axis)
+
+def min(x, axis=0):
+ return _Nmin(x, axis)
+
+def prod(x, axis=0):
+ return _Nprod(x, axis)
+
+def std(x, axis=0):
+ return _Nstd(x, axis)
+
+def mean(x, axis=0):
+ return _Nmean(x, axis)
+
+def cov(m, y=None, rowvar=0, bias=0):
+ return _Ncov(m, y, rowvar, bias)
+
+def corrcoef(x, y=None):
+ return _Ncorrcoef(x,y,0,0)
+
+
diff --git a/numpy/oldnumeric/olddefaults.py b/numpy/oldnumeric/olddefaults.py
index 356f5f00c..384261437 100644
--- a/numpy/oldnumeric/olddefaults.py
+++ b/numpy/oldnumeric/olddefaults.py
@@ -1,45 +1,32 @@
-__all__ = ['ones', 'empty', 'identity', 'zeros', 'eye', 'tri']
+__all__ = ['ones', 'empty', 'identity', 'zeros']
import numpy.core.multiarray as mu
import numpy.core.numeric as nn
-
-def ones(shape, dtype=int, order='C'):
+from typeconv import convtypecode
+
+def ones(shape, typecode='l', savespace=0, dtype=None):
"""ones(shape, dtype=int) returns an array of the given
dimensions which is initialized to all ones.
"""
- a = mu.empty(shape, dtype, order)
+ dtype = convtypecode(typecode,dtype)
+ a = mu.empty(shape, dtype)
a.fill(1)
return a
-def zeros(shape, dtype=int, order='C'):
+def zeros(shape, typecode='l', savespace=0, dtype=None):
"""zeros(shape, dtype=int) returns an array of the given
dimensions which is initialized to all zeros
"""
- return mu.zeros(shape, dtype, order)
+ dtype = convtypecode(typecode,dtype)
+ return mu.zeros(shape, dtype)
-def identity(n,dtype=int):
+def identity(n,typecode='l', dtype=None):
"""identity(n) returns the identity 2-d array of shape n x n.
"""
+ dtype = convtypecode(typecode, dtype)
return nn.identity(n, dtype)
-def eye(N, M=None, k=0, dtype=int):
- """ eye returns a N-by-M 2-d array where the k-th diagonal is all ones,
- and everything else is zeros.
- """
- if M is None: M = N
- m = nn.equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k)
- if m.dtype != dtype:
- return m.astype(dtype)
-
-def tri(N, M=None, k=0, dtype=int):
- """ returns a N-by-M array where all the diagonals starting from
- lower left corner up to the k-th are all ones.
- """
- if M is None: M = N
- m = nn.greater_equal(nn.subtract.outer(nn.arange(N), nn.arange(M)),-k)
- if m.dtype != dtype:
- return m.astype(dtype)
-
-def empty(shape, dtype=int, order='C'):
+def empty(shape, typecode='l', dtype=None):
+ dtype = convtypecode(typecode, dtype)
return mu.empty(shape, dtype, order)
diff --git a/numpy/random/old.py b/numpy/oldnumeric/random_array.py
index 414dc5215..061465d02 100644
--- a/numpy/random/old.py
+++ b/numpy/oldnumeric/random_array.py
@@ -1,3 +1,4 @@
+# Backward compatible module for RandomArray
__all__ = ['ArgumentError','F','beta','binomial','chi_square', 'exponential', 'gamma', 'get_seed',
'mean_var_test', 'multinomial', 'multivariate_normal', 'negative_binomial',
diff --git a/numpy/random/oldrng.py b/numpy/oldnumeric/rng.py
index 1e6b2fbd6..77a90c694 100644
--- a/numpy/random/oldrng.py
+++ b/numpy/oldnumeric/rng.py
@@ -1,5 +1,5 @@
# This module re-creates the RNG interface from Numeric
-# Replace import RNG with import numpy.random.oldrng as RNG
+# Replace import RNG with import numpy.oldnumeric.rng as RNG
#
# It is for backwards compatibility only.
@@ -134,3 +134,4 @@ def random_sample(*n):
m = m * i
return standard_generator.sample(m).reshape(*n)
+
diff --git a/numpy/random/oldrngstats.py b/numpy/oldnumeric/rng_stats.py
index 60248247e..60248247e 100644
--- a/numpy/random/oldrngstats.py
+++ b/numpy/oldnumeric/rng_stats.py
diff --git a/numpy/setup.py b/numpy/setup.py
index c2e6be49b..61538ec28 100644
--- a/numpy/setup.py
+++ b/numpy/setup.py
@@ -11,6 +11,7 @@ def configuration(parent_package='',top_path=None):
config.add_subpackage('oldnumeric')
config.add_subpackage('numarray')
config.add_subpackage('dft')
+ config.add_subpackage('fft')
config.add_subpackage('linalg')
config.add_subpackage('random')
config.add_data_dir('doc')