diff options
| author | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 21:05:36 +0000 |
|---|---|---|
| committer | Travis Oliphant <oliphant@enthought.com> | 2006-01-04 21:05:36 +0000 |
| commit | 490712cd35dcecfc9423de4bde0b29cb012dda25 (patch) | |
| tree | 56b6ccaac48afc370a189c596d5e9e90ac0254d4 | |
| parent | 7ff852162596a8eaa02ef87730474285b080d594 (diff) | |
| download | numpy-490712cd35dcecfc9423de4bde0b29cb012dda25.tar.gz | |
More numpy fixes...
| -rw-r--r-- | numpy/__init__.py | 18 | ||||
| -rw-r--r-- | numpy/core/__init__.py | 4 | ||||
| -rw-r--r-- | numpy/core/code_generators/generate_array_api.py | 4 | ||||
| -rw-r--r-- | numpy/core/code_generators/generate_ufunc_api.py | 2 | ||||
| -rw-r--r-- | numpy/core/defmatrix.py (renamed from numpy/core/matrix.py) | 5 | ||||
| -rw-r--r-- | numpy/core/info.py | 121 | ||||
| -rw-r--r-- | numpy/core/ma.py | 3 | ||||
| -rw-r--r-- | numpy/core/numeric.py | 50 | ||||
| -rw-r--r-- | numpy/core/oldnumeric.py | 32 | ||||
| -rw-r--r-- | numpy/core/src/arraytypes.inc.src | 2 | ||||
| -rw-r--r-- | numpy/core/src/multiarraymodule.c | 8 | ||||
| -rw-r--r-- | numpy/core/src/scalartypes.inc.src | 8 | ||||
| -rw-r--r-- | numpy/dft/fftpack.py | 2 | ||||
| -rw-r--r-- | numpy/dft/helper.py | 4 | ||||
| -rw-r--r-- | numpy/dft/info.py | 2 | ||||
| -rw-r--r-- | numpy/lib/function_base.py | 77 | ||||
| -rw-r--r-- | numpy/lib/getlimits.py | 2 | ||||
| -rw-r--r-- | numpy/lib/index_tricks.py | 7 | ||||
| -rw-r--r-- | numpy/lib/info.py | 121 | ||||
| -rw-r--r-- | numpy/lib/src/_compiled_base.c | 4 | ||||
| -rw-r--r-- | numpy/linalg/info.py | 2 | ||||
| -rw-r--r-- | numpy/linalg/linalg.py | 2 | ||||
| -rw-r--r-- | numpy/random/info.py | 2 |
23 files changed, 240 insertions, 242 deletions
diff --git a/numpy/__init__.py b/numpy/__init__.py index c678218b0..b2039319a 100644 --- a/numpy/__init__.py +++ b/numpy/__init__.py @@ -17,8 +17,7 @@ Available subpackages """ import os, sys -NO_SCIPY_IMPORT = os.environ.get('NO_SCIPY_IMPORT',None) -SCIPY_IMPORT_VERBOSE = int(os.environ.get('SCIPY_IMPORT_VERBOSE','0')) +NUMPY_IMPORT_VERBOSE = int(os.environ.get('NUMPY_IMPORT_VERBOSE','0')) try: from __core_config__ import show as show_core_config @@ -299,10 +298,10 @@ pkgload = PackageLoader() if show_core_config is None: print >> sys.stderr, 'Running from numpy core source directory.' else: - from core_version import version as __core_version__ + from version import version as __version__ - pkgload('testing','base','corefft','corelinalg','random', - verbose=SCIPY_IMPORT_VERBOSE) + pkgload('testing','core','lib','dft','linalg','random', + verbose=NUMPY_IMPORT_VERBOSE) test = ScipyTest('numpy').test @@ -310,17 +309,14 @@ else: __numpy_doc__ = """ -SciPy: A scientific computing package for Python +NumPy: A scientific computing package for Python ================================================ Available subpackages --------------------- """ -if NO_SCIPY_IMPORT is not None: - print >> sys.stderr, 'Skip importing numpy packages (NO_SCIPY_IMPORT=%s)' % (NO_SCIPY_IMPORT) - show_numpy_config = None -elif show_core_config is None: +if show_core_config is None: show_numpy_config = None else: try: @@ -332,4 +328,4 @@ else: if show_numpy_config is not None: from numpy_version import numpy_version as __numpy_version__ __doc__ += __numpy_doc__ - pkgload(verbose=SCIPY_IMPORT_VERBOSE,postpone=True) + pkgload(verbose=NUMPY_IMPORT_VERBOSE,postpone=True) diff --git a/numpy/core/__init__.py b/numpy/core/__init__.py index b10f561f5..8ff2bf565 100644 --- a/numpy/core/__init__.py +++ b/numpy/core/__init__.py @@ -1,6 +1,6 @@ from info import __doc__ -from numpy.core_version import version as __version__ +from numpy.version import version as __version__ import multiarray import umath @@ -9,7 +9,7 @@ multiarray.set_typeDict(nt.typeDict) import _sort from numeric import * from oldnumeric import * -from matrix import * +from defmatrix import * import ma import chararray as char import records as rec diff --git a/numpy/core/code_generators/generate_array_api.py b/numpy/core/code_generators/generate_array_api.py index 6d2bce00d..db8086903 100644 --- a/numpy/core/code_generators/generate_array_api.py +++ b/numpy/core/code_generators/generate_array_api.py @@ -1,7 +1,7 @@ import os import genapi -types = ['Generic','Numeric','Integer','SignedInteger','UnsignedInteger', +types = ['Generic','Number','Integer','SignedInteger','UnsignedInteger', 'Inexact', 'Floating', 'ComplexFloating', 'Flexible', 'Character', 'Bool','Byte','Short','Int', 'Long', 'LongLong', 'UByte', 'UShort', @@ -51,7 +51,7 @@ static void **PyArray_API=NULL; static int import_array(void) { - PyObject *numpy = PyImport_ImportModule("numpy.base.multiarray"); + PyObject *numpy = PyImport_ImportModule("numpy.core.multiarray"); PyObject *c_api = NULL; if (numpy == NULL) return -1; c_api = PyObject_GetAttrString(numpy, "_ARRAY_API"); diff --git a/numpy/core/code_generators/generate_ufunc_api.py b/numpy/core/code_generators/generate_ufunc_api.py index 6c9307058..6545a4642 100644 --- a/numpy/core/code_generators/generate_ufunc_api.py +++ b/numpy/core/code_generators/generate_ufunc_api.py @@ -31,7 +31,7 @@ static void **PyUFunc_API=NULL; static int import_ufunc(void) { - PyObject *numpy = PyImport_ImportModule("numpy.base.umath"); + PyObject *numpy = PyImport_ImportModule("numpy.core.umath"); PyObject *c_api = NULL; if (numpy == NULL) return -1; diff --git a/numpy/core/matrix.py b/numpy/core/defmatrix.py index 0b064ddd7..4b6f4bc2c 100644 --- a/numpy/core/matrix.py +++ b/numpy/core/defmatrix.py @@ -2,9 +2,8 @@ __all__ = ['matrix', 'bmat', 'mat', 'asmatrix'] import numeric as N -from numeric import ArrayType, concatenate, integer, multiply, power -from type_check import isscalar -from function_base import binary_repr +from numeric import ArrayType, concatenate, integer, multiply, power, \ + isscalar, binary_repr import types import string as str_ import sys diff --git a/numpy/core/info.py b/numpy/core/info.py index b4c4b4e8c..30071426b 100644 --- a/numpy/core/info.py +++ b/numpy/core/info.py @@ -82,127 +82,6 @@ More Functions: arccosh arcsinh arctanh """ -__doc__ += \ -""" Basic functions used by several sub-packages and useful to have in the -main name-space - -Type handling -============== -iscomplexobj -- Test for complex object, scalar result -isrealobj -- Test for real object, scalar result -iscomplex -- Test for complex elements, array result -isreal -- Test for real elements, array result -imag -- Imaginary part -real -- Real part -real_if_close -- Turns complex number with tiny imaginary part to real -isneginf -- Tests for negative infinity ---| -isposinf -- Tests for positive infinity | -isnan -- Tests for nans |---- array results -isinf -- Tests for infinity | -isfinite -- Tests for finite numbers ---| -isscalar -- True if argument is a scalar -nan_to_num -- Replaces NaN's with 0 and infinities with large numbers -cast -- Dictionary of functions to force cast to each type -common_type -- Determine the 'minimum common type code' for a group - of arrays -mintypecode -- Return minimal allowed common typecode. - -Index tricks -================== -mgrid -- Method which allows easy construction of N-d 'mesh-grids' -r_ -- Append and construct arrays: turns slice objects into - ranges and concatenates them, for 2d arrays appends - rows. -index_exp -- Konrad Hinsen's index_expression class instance which - can be useful for building complicated slicing syntax. - -Useful functions -================== -select -- Extension of where to multiple conditions and choices -extract -- Extract 1d array from flattened array according to mask -insert -- Insert 1d array of values into Nd array according to mask -linspace -- Evenly spaced samples in linear space -logspace -- Evenly spaced samples in logarithmic space -fix -- Round x to nearest integer towards zero -mod -- Modulo mod(x,y) = x % y except keeps sign of y -amax -- Array maximum along axis -amin -- Array minimum along axis -ptp -- Array max-min along axis -cumsum -- Cumulative sum along axis -prod -- Product of elements along axis -cumprod -- Cumluative product along axis -diff -- Discrete differences along axis -angle -- Returns angle of complex argument -unwrap -- Unwrap phase along given axis (1-d algorithm) -sort_complex -- Sort a complex-array (based on real, then imaginary) -trim_zeros -- trim the leading and trailing zeros from 1D array. - -vectorize -- a class that wraps a Python function taking scalar - arguments into a generalized function which - can handle arrays of arguments using the broadcast - rules of numerix Python. - -alter_numeric -- enhance numeric array behavior -restore_numeric -- restore alterations done by alter_numeric - -Shape manipulation -=================== -squeeze -- Return a with length-one dimensions removed. -atleast_1d -- Force arrays to be > 1D -atleast_2d -- Force arrays to be > 2D -atleast_3d -- Force arrays to be > 3D -vstack -- Stack arrays vertically (row on row) -hstack -- Stack arrays horizontally (column on column) -column_stack -- Stack 1D arrays as columns into 2D array -dstack -- Stack arrays depthwise (along third dimension) -split -- Divide array into a list of sub-arrays -hsplit -- Split into columns -vsplit -- Split into rows -dsplit -- Split along third dimension - -Matrix (2d array) manipluations -=============================== -fliplr -- 2D array with columns flipped -flipud -- 2D array with rows flipped -rot90 -- Rotate a 2D array a multiple of 90 degrees -eye -- Return a 2D array with ones down a given diagonal -diag -- Construct a 2D array from a vector, or return a given - diagonal from a 2D array. -mat -- Construct a Matrix -bmat -- Build a Matrix from blocks - -Polynomials -============ -poly1d -- A one-dimensional polynomial class - -poly -- Return polynomial coefficients from roots -roots -- Find roots of polynomial given coefficients -polyint -- Integrate polynomial -polyder -- Differentiate polynomial -polyadd -- Add polynomials -polysub -- Substract polynomials -polymul -- Multiply polynomials -polydiv -- Divide polynomials -polyval -- Evaluate polynomial at given argument - -Import tricks -============= -ppimport -- Postpone module import until trying to use it -ppimport_attr -- Postpone module import until trying to use its - attribute -ppresolve -- Import postponed module and return it. - -Machine arithmetics -=================== -machar_single -- MachAr instance storing the parameters of system - single precision floating point arithmetics -machar_double -- MachAr instance storing the parameters of system - double precision floating point arithmetics - -Threading tricks -================ -ParallelExec -- Execute commands in parallel thread. -""" depends = ['testing'] global_symbols = ['*'] diff --git a/numpy/core/ma.py b/numpy/core/ma.py index 439c311ab..3c3394599 100644 --- a/numpy/core/ma.py +++ b/numpy/core/ma.py @@ -11,7 +11,6 @@ import string, types, sys import umath import oldnumeric -import function_base from numeric import e, pi, newaxis, ndarray, inf from oldnumeric import typecodes, amax, amin from numerictypes import * @@ -468,7 +467,7 @@ absolute = masked_unary_operation(umath.absolute) fabs = masked_unary_operation(umath.fabs) negative = masked_unary_operation(umath.negative) nonzero = masked_unary_operation(oldnumeric.nonzero) -around = masked_unary_operation(function_base.round_) +around = masked_unary_operation(oldnumeric.round_) floor = masked_unary_operation(umath.floor) ceil = masked_unary_operation(umath.ceil) sometrue = masked_unary_operation(oldnumeric.sometrue) diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 03a2e520f..7cdebbf5d 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -10,7 +10,7 @@ __all__ = ['newaxis', 'ndarray', 'bigndarray', 'flatiter', 'ufunc', 'array_repr', 'array_str', 'set_string_function', 'little_endian', 'indices', 'fromfunction', - 'load', 'loads', + 'load', 'loads', 'isscalar', 'binary_repr', 'base_repr', 'ones', 'identity', 'allclose', 'seterr', 'geterr', 'setbufsize', 'getbufsize', 'seterrcall', 'geterrcall', @@ -271,6 +271,54 @@ def fromfunction(function, dimensions, **kwargs): args = indices(dimensions) return function(*args,**kwargs) +def isscalar(num): + if isinstance(num, generic): + return True + else: + return type(num) in ScalarType + +_lkup = {'0':'000', + '1':'001', + '2':'010', + '3':'011', + '4':'100', + '5':'101', + '6':'110', + '7':'111', + 'L':''} + +def binary_repr(num): + """Return the binary representation of the input number as a string. + + This is equivalent to using base_repr with base 2, but about 25x + faster. + """ + ostr = oct(num) + bin = '' + for ch in ostr[1:]: + bin += _lkup[ch] + ind = 0 + while bin[ind] == '0': + ind += 1 + return bin[ind:] + +def base_repr (number, base=2, padding=0): + """Return the representation of a number in any given base. + """ + chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' + + lnb = math.log(base) + res = padding*chars[0] + if number == 0: + return res + chars[0] + exponent = int (math.log (number)/lnb) + while(exponent >= 0): + term = long(base)**exponent + lead_digit = int(number / term) + res += chars[lead_digit] + number -= term*lead_digit + exponent -= 1 + return res from cPickle import load, loads _cload = load diff --git a/numpy/core/oldnumeric.py b/numpy/core/oldnumeric.py index 9cf87218e..833a2176e 100644 --- a/numpy/core/oldnumeric.py +++ b/numpy/core/oldnumeric.py @@ -23,7 +23,8 @@ __all__ = ['asarray', 'array', 'concatenate', 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape', 'compress', 'clip', 'sum', 'product', 'prod', 'sometrue', 'alltrue', 'any', 'all', 'cumsum', 'cumproduct', 'cumprod', 'ptp', 'ndim', - 'rank', 'size', 'around', 'mean', 'std', 'var', 'squeeze', 'amax', 'amin' + 'rank', 'size', 'around', 'round_', 'mean', 'std', 'var', 'squeeze', + 'amax', 'amin' ] import multiarray as mu @@ -420,7 +421,34 @@ def size (a, axis=None): except AttributeError: return asarray(a).shape[axis] -from function_base import round_ as around +def round_(a, decimals=0): + """Round 'a' to the given number of decimal places. Rounding + behaviour is equivalent to Python. + + Return 'a' if the array is not floating point. Round both the real + and imaginary parts separately if the array is complex. + """ + a = asarray(a) + if not issubclass(a.dtype, _nx.inexact): + return a + if issubclass(a.dtype, _nx.complexfloating): + return round_(a.real, decimals) + 1j*round_(a.imag, decimals) + if decimals is not 0: + decimals = asarray(decimals) + s = sign(a) + if decimals is not 0: + a = absolute(multiply(a, 10.**decimals)) + else: + a = absolute(a) + rem = a-asarray(a).astype(_nx.intp) + a = _nx.where(_nx.less(rem, 0.5), _nx.floor(a), _nx.ceil(a)) + # convert back + if decimals is not 0: + return multiply(a, s/(10.**decimals)) + else: + return multiply(a, s) + +around = round_ def mean(a, axis=0, dtype=None): return asarray(a).mean(axis, dtype) diff --git a/numpy/core/src/arraytypes.inc.src b/numpy/core/src/arraytypes.inc.src index 322eafef8..773ffb320 100644 --- a/numpy/core/src/arraytypes.inc.src +++ b/numpy/core/src/arraytypes.inc.src @@ -1892,7 +1892,7 @@ set_typeinfo(PyObject *dict) (PyObject *)&Py##name##ArrType_Type); SETTYPE(Generic) - SETTYPE(Numeric) + SETTYPE(Number) SETTYPE(Integer) SETTYPE(Inexact) SETTYPE(SignedInteger) diff --git a/numpy/core/src/multiarraymodule.c b/numpy/core/src/multiarraymodule.c index 6c993b069..7f6ceb8a9 100644 --- a/numpy/core/src/multiarraymodule.c +++ b/numpy/core/src/multiarraymodule.c @@ -5288,9 +5288,9 @@ setup_scalartypes(PyObject *dict) if (PyType_Ready(&PyGenericArrType_Type) < 0) return -1; - SINGLE_INHERIT(Numeric, Generic); - SINGLE_INHERIT(Integer, Numeric); - SINGLE_INHERIT(Inexact, Numeric); + SINGLE_INHERIT(Number, Generic); + SINGLE_INHERIT(Integer, Number); + SINGLE_INHERIT(Inexact, Number); SINGLE_INHERIT(SignedInteger, Integer); SINGLE_INHERIT(UnsignedInteger, Integer); SINGLE_INHERIT(Floating, Inexact); @@ -5493,7 +5493,7 @@ DL_EXPORT(void) initmultiarray(void) { if (set_typeinfo(d) != 0) goto err; _numpy_internal = \ - PyImport_ImportModule("numpy.base._internal"); + PyImport_ImportModule("numpy.core._internal"); if (_numpy_internal != NULL) return; err: diff --git a/numpy/core/src/scalartypes.inc.src b/numpy/core/src/scalartypes.inc.src index 972b2424f..4d3c4cd28 100644 --- a/numpy/core/src/scalartypes.inc.src +++ b/numpy/core/src/scalartypes.inc.src @@ -19,9 +19,9 @@ typedef struct { /**begin repeat -#name=numeric, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, +#name=number, integer, signedinteger, unsignedinteger, inexact, floating, complexfloating, flexible, character# -#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character# +#NAME=Number, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character# */ static PyTypeObject Py@NAME@ArrType_Type = { @@ -1925,7 +1925,7 @@ initialize_numeric_types(void) PyVoidArrType_Type.tp_as_mapping = &voidtype_as_mapping; /**begin repeat -#NAME=Numeric, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, +#NAME=Number, Integer, SignedInteger, UnsignedInteger, Inexact, Floating, ComplexFloating, Flexible, Character# */ Py@NAME@ArrType_Type.tp_flags = BASEFLAGS; @@ -2064,7 +2064,7 @@ PyArray_DescrFromTypeObject(PyObject *type) } /* Check the generic types */ - if ((type == (PyObject *) &PyNumericArrType_Type) || \ + if ((type == (PyObject *) &PyNumberArrType_Type) || \ (type == (PyObject *) &PyInexactArrType_Type) || \ (type == (PyObject *) &PyFloatingArrType_Type)) typenum = PyArray_DOUBLE; diff --git a/numpy/dft/fftpack.py b/numpy/dft/fftpack.py index fdaf65bce..2cd3d8f8a 100644 --- a/numpy/dft/fftpack.py +++ b/numpy/dft/fftpack.py @@ -26,7 +26,7 @@ __all__ = ['fft','inverse_fft', 'ifft', 'real_fft', 'refft', 'inverse_real_fft', 'inverse_fft2d', 'real_fftnd', 'real_fft2d', 'inverse_real_fftnd', 'inverse_real_fft2d',] -from numpy.base import * +from numpy.core import * import fftpack_lite as fftpack from helper import * diff --git a/numpy/dft/helper.py b/numpy/dft/helper.py index d5ed9940b..b402eb9ae 100644 --- a/numpy/dft/helper.py +++ b/numpy/dft/helper.py @@ -5,8 +5,8 @@ Discrete Fourier Transforms - helper.py __all__ = ['fftshift','ifftshift','fftfreq'] -from numpy.base import asarray, concatenate, arange, take, \ - array, integer +from numpy.core import asarray, concatenate, arange, take, \ + array, integer import types def fftshift(x,axes=None): diff --git a/numpy/dft/info.py b/numpy/dft/info.py index 62c5c0630..8b81b8669 100644 --- a/numpy/dft/info.py +++ b/numpy/dft/info.py @@ -26,5 +26,5 @@ Core FFT routines ihfft """ -depends = ['base'] +depends = ['core'] global_symbols = ['fft','ifft'] diff --git a/numpy/lib/function_base.py b/numpy/lib/function_base.py index 694c727ed..bfaa90a94 100644 --- a/numpy/lib/function_base.py +++ b/numpy/lib/function_base.py @@ -1,5 +1,5 @@ -l__all__ = ['logspace', 'linspace', 'round_', +l__all__ = ['logspace', 'linspace', 'select', 'piecewise', 'trim_zeros', 'copy', 'iterable', 'base_repr', 'binary_repr', 'diff', 'gradient', 'angle', 'unwrap', 'sort_complex', 'disp', @@ -14,60 +14,18 @@ import types import math import numpy.core.numeric as _nx from numpy.core.numeric import ones, zeros, arange, concatenate, array, asarray, empty -from numpy.core.numeric import ScalarType, dot, where, newaxis +from numpy.core.numeric import ScalarType, dot, where, newaxis, isscalar from numpy.core.umath import pi, multiply, add, arctan2, maximum, minimum, frompyfunc, \ isnan, absolute, cos, less_equal, sqrt, sin, mod from numpy.core.oldnumeric import ravel, nonzero, choose, \ sometrue, alltrue, reshape, any, all, typecodes, ArrayType, squeeze,\ sort -from type_check import ScalarType, isscalar +from type_check import ScalarType from shape_base import atleast_1d from twodim_base import diag from _compiled_base import digitize, bincount, _insert from ufunclike import sign -_lkup = {'0':'000', - '1':'001', - '2':'010', - '3':'011', - '4':'100', - '5':'101', - '6':'110', - '7':'111', - 'L':''} - -def binary_repr(num): - """Return the binary representation of the input number as a string. - - This is equivalent to using base_repr with base 2, but about 25x - faster. - """ - ostr = oct(num) - bin = '' - for ch in ostr[1:]: - bin += _lkup[ch] - ind = 0 - while bin[ind] == '0': - ind += 1 - return bin[ind:] - -def base_repr (number, base=2, padding=0): - """Return the representation of a number in any given base. - """ - chars = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ' - - lnb = math.log(base) - res = padding*chars[0] - if number == 0: - return res + chars[0] - exponent = int (math.log (number)/lnb) - while(exponent >= 0): - term = long(base)**exponent - lead_digit = int(number / term) - res += chars[lead_digit] - number -= term*lead_digit - exponent -= 1 - return res #end Fernando's utilities @@ -665,35 +623,6 @@ class vectorize(object): else: return tuple([x.astype(c) for x, c in zip(self.ufunc(*args), self.otypes)]) - -def round_(a, decimals=0): - """Round 'a' to the given number of decimal places. Rounding - behaviour is equivalent to Python. - - Return 'a' if the array is not floating point. Round both the real - and imaginary parts separately if the array is complex. - """ - a = asarray(a) - if not issubclass(a.dtype, _nx.inexact): - return a - if issubclass(a.dtype, _nx.complexfloating): - return round_(a.real, decimals) + 1j*round_(a.imag, decimals) - if decimals is not 0: - decimals = asarray(decimals) - s = sign(a) - if decimals is not 0: - a = absolute(multiply(a, 10.**decimals)) - else: - a = absolute(a) - rem = a-asarray(a).astype(_nx.intp) - a = _nx.where(_nx.less(rem, 0.5), _nx.floor(a), _nx.ceil(a)) - # convert back - if decimals is not 0: - return multiply(a, s/(10.**decimals)) - else: - return multiply(a, s) - - def cov(m,y=None, rowvar=0, bias=0): """Estimate the covariance matrix. diff --git a/numpy/lib/getlimits.py b/numpy/lib/getlimits.py index 825f286e8..3b5bd9211 100644 --- a/numpy/lib/getlimits.py +++ b/numpy/lib/getlimits.py @@ -4,7 +4,7 @@ __all__ = ['finfo'] from machar import MachAr -import numpy.core.numeric +import numpy.core.numeric as numeric from numpy.core.numeric import array def _frz(a): diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index e2c8d2a13..c380df0d8 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -4,13 +4,12 @@ __all__ = ['mgrid','ogrid','r_', 'c_', 'index_exp', 'ix_','ndenumerate'] import sys import types -import numeric as _nx -from numeric import asarray +import numpy.core.numeric as _nx +from numpy.core.numeric import asarray, ScalarType -from type_check import ScalarType import function_base import twodim_base as matrix_base -import matrix +import numpy.core.defmatrix as matrix makemat = matrix.matrix def ix_(*args): diff --git a/numpy/lib/info.py b/numpy/lib/info.py new file mode 100644 index 000000000..e7b097f1b --- /dev/null +++ b/numpy/lib/info.py @@ -0,0 +1,121 @@ +__doc__ = \ +""" Basic functions used by several sub-packages and useful to have in the +main name-space + +Type handling +============== +iscomplexobj -- Test for complex object, scalar result +isrealobj -- Test for real object, scalar result +iscomplex -- Test for complex elements, array result +isreal -- Test for real elements, array result +imag -- Imaginary part +real -- Real part +real_if_close -- Turns complex number with tiny imaginary part to real +isneginf -- Tests for negative infinity ---| +isposinf -- Tests for positive infinity | +isnan -- Tests for nans |---- array results +isinf -- Tests for infinity | +isfinite -- Tests for finite numbers ---| +isscalar -- True if argument is a scalar +nan_to_num -- Replaces NaN's with 0 and infinities with large numbers +cast -- Dictionary of functions to force cast to each type +common_type -- Determine the 'minimum common type code' for a group + of arrays +mintypecode -- Return minimal allowed common typecode. + +Index tricks +================== +mgrid -- Method which allows easy construction of N-d 'mesh-grids' +r_ -- Append and construct arrays: turns slice objects into + ranges and concatenates them, for 2d arrays appends + rows. +index_exp -- Konrad Hinsen's index_expression class instance which + can be useful for building complicated slicing syntax. + +Useful functions +================== +select -- Extension of where to multiple conditions and choices +extract -- Extract 1d array from flattened array according to mask +insert -- Insert 1d array of values into Nd array according to mask +linspace -- Evenly spaced samples in linear space +logspace -- Evenly spaced samples in logarithmic space +fix -- Round x to nearest integer towards zero +mod -- Modulo mod(x,y) = x % y except keeps sign of y +amax -- Array maximum along axis +amin -- Array minimum along axis +ptp -- Array max-min along axis +cumsum -- Cumulative sum along axis +prod -- Product of elements along axis +cumprod -- Cumluative product along axis +diff -- Discrete differences along axis +angle -- Returns angle of complex argument +unwrap -- Unwrap phase along given axis (1-d algorithm) +sort_complex -- Sort a complex-array (based on real, then imaginary) +trim_zeros -- trim the leading and trailing zeros from 1D array. + +vectorize -- a class that wraps a Python function taking scalar + arguments into a generalized function which + can handle arrays of arguments using the broadcast + rules of numerix Python. + +Shape manipulation +=================== +squeeze -- Return a with length-one dimensions removed. +atleast_1d -- Force arrays to be > 1D +atleast_2d -- Force arrays to be > 2D +atleast_3d -- Force arrays to be > 3D +vstack -- Stack arrays vertically (row on row) +hstack -- Stack arrays horizontally (column on column) +column_stack -- Stack 1D arrays as columns into 2D array +dstack -- Stack arrays depthwise (along third dimension) +split -- Divide array into a list of sub-arrays +hsplit -- Split into columns +vsplit -- Split into rows +dsplit -- Split along third dimension + +Matrix (2d array) manipluations +=============================== +fliplr -- 2D array with columns flipped +flipud -- 2D array with rows flipped +rot90 -- Rotate a 2D array a multiple of 90 degrees +eye -- Return a 2D array with ones down a given diagonal +diag -- Construct a 2D array from a vector, or return a given + diagonal from a 2D array. +mat -- Construct a Matrix +bmat -- Build a Matrix from blocks + +Polynomials +============ +poly1d -- A one-dimensional polynomial class + +poly -- Return polynomial coefficients from roots +roots -- Find roots of polynomial given coefficients +polyint -- Integrate polynomial +polyder -- Differentiate polynomial +polyadd -- Add polynomials +polysub -- Substract polynomials +polymul -- Multiply polynomials +polydiv -- Divide polynomials +polyval -- Evaluate polynomial at given argument + +Import tricks +============= +ppimport -- Postpone module import until trying to use it +ppimport_attr -- Postpone module import until trying to use its + attribute +ppresolve -- Import postponed module and return it. + +Machine arithmetics +=================== +machar_single -- MachAr instance storing the parameters of system + single precision floating point arithmetics +machar_double -- MachAr instance storing the parameters of system + double precision floating point arithmetics + +Threading tricks +================ +ParallelExec -- Execute commands in parallel thread. +""" + +depends = ['core','testing'] +global_symbols = ['*'] diff --git a/numpy/lib/src/_compiled_base.c b/numpy/lib/src/_compiled_base.c index 7c20d4f96..063631c7e 100644 --- a/numpy/lib/src/_compiled_base.c +++ b/numpy/lib/src/_compiled_base.c @@ -427,7 +427,7 @@ DL_EXPORT(void) init_compiled_base(void) { PyObject *m, *d, *s; /* Create the module and add the functions */ - m = Py_InitModule("numpy.base._compiled_base", methods); + m = Py_InitModule("_compiled_base", methods); /* Import the array and ufunc objects */ import_array(); @@ -439,7 +439,7 @@ DL_EXPORT(void) init_compiled_base(void) { PyDict_SetItemString(d, "__version__", s); Py_DECREF(s); - ErrorObject = PyString_FromString("numpy.base._compiled_base.error"); + ErrorObject = PyString_FromString("numpy.lib._compiled_base.error"); PyDict_SetItemString(d, "error", ErrorObject); Py_DECREF(ErrorObject); diff --git a/numpy/linalg/info.py b/numpy/linalg/info.py index 740dfcc1a..da6a9df20 100644 --- a/numpy/linalg/info.py +++ b/numpy/linalg/info.py @@ -21,5 +21,5 @@ Core Linear Algebra Tools """ -depends = ['base'] +depends = ['core'] diff --git a/numpy/linalg/linalg.py b/numpy/linalg/linalg.py index 5ae5b5592..8db1f4e18 100644 --- a/numpy/linalg/linalg.py +++ b/numpy/linalg/linalg.py @@ -12,7 +12,7 @@ __all__ = ['LinAlgError', 'solve_linear_equations', 'solve', 'eigenvectors', 'eig', 'Heigenvectors', 'eigh','lstsq', 'linear_least_squares' ] -from numpy.base import * +from numpy.core import * import lapack_lite import math diff --git a/numpy/random/info.py b/numpy/random/info.py index 44864495e..060cd3993 100644 --- a/numpy/random/info.py +++ b/numpy/random/info.py @@ -4,7 +4,7 @@ Core Random Tools """ -depends = ['base'] +depends = ['core'] global_symbols = ['rand','randn'] __all__ = [ |
