diff options
author | Travis Oliphant <oliphant@enthought.com> | 2006-08-04 23:32:12 +0000 |
---|---|---|
committer | Travis Oliphant <oliphant@enthought.com> | 2006-08-04 23:32:12 +0000 |
commit | f1cca04886d4f63f7b1ed5b382986af3a9ee6a61 (patch) | |
tree | 053f566b31cb6edc24a41b800ec7f2972c4bca40 /numpy/oldnumeric/mlab.py | |
parent | 8f26568de7cc97ac0dcedfd5061e08bb54770b61 (diff) | |
download | numpy-f1cca04886d4f63f7b1ed5b382986af3a9ee6a61.tar.gz |
Many name-changes in oldnumeric. This may break some numpy code that was using the oldnumeric interface.
Diffstat (limited to 'numpy/oldnumeric/mlab.py')
-rw-r--r-- | numpy/oldnumeric/mlab.py | 72 |
1 files changed, 72 insertions, 0 deletions
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) + + |