diff options
Diffstat (limited to 'numpy')
-rw-r--r-- | numpy/add_newdocs.py | 2 | ||||
-rw-r--r-- | numpy/core/blasdot/_dotblas.c | 2 | ||||
-rw-r--r-- | numpy/core/fromnumeric.py | 48 | ||||
-rw-r--r-- | numpy/core/numeric.py | 6 | ||||
-rw-r--r-- | numpy/lib/tests/test_function_base.py | 4 | ||||
-rw-r--r-- | numpy/oldnumeric/__init__.py | 12 | ||||
-rw-r--r-- | numpy/oldnumeric/compat.py | 4 |
7 files changed, 45 insertions, 33 deletions
diff --git a/numpy/add_newdocs.py b/numpy/add_newdocs.py index 357ee80b0..98a9cbaa4 100644 --- a/numpy/add_newdocs.py +++ b/numpy/add_newdocs.py @@ -226,7 +226,7 @@ byteswapped, but the array will manage it in future operations. """) add_newdoc('numpy.core.multiarray','concatenate', -"""concatenate((a1, a2, ...), axis=None) +"""concatenate((a1, a2, ...), axis=0) Join arrays together. diff --git a/numpy/core/blasdot/_dotblas.c b/numpy/core/blasdot/_dotblas.c index 91b50b43b..950bf7179 100644 --- a/numpy/core/blasdot/_dotblas.c +++ b/numpy/core/blasdot/_dotblas.c @@ -172,7 +172,7 @@ _select_matrix_shape(PyArrayObject *array) } -static char doc_matrixproduct[] = "matrixproduct(a,b)\nReturns the dot product of a and b for arrays of floating point types.\nLike the generic numpy equivalent the product sum is over\nthe last dimension of a and the second-to-last dimension of b.\nNB: The first argument is not conjugated."; +static char doc_matrixproduct[] = "dot(a,b)\nReturns the dot product of a and b for arrays of floating point types.\nLike the generic numpy equivalent the product sum is over\nthe last dimension of a and the second-to-last dimension of b.\nNB: The first argument is not conjugated."; static PyObject * dotblas_matrixproduct(PyObject *dummy, PyObject *args) diff --git a/numpy/core/fromnumeric.py b/numpy/core/fromnumeric.py index 67d39cbcd..38cf0aabf 100644 --- a/numpy/core/fromnumeric.py +++ b/numpy/core/fromnumeric.py @@ -1,8 +1,7 @@ # Module containing non-deprecated functions borrowed from Numeric. -__all__ = ['asarray', 'array', 'concatenate', - # functions that are now methods - 'take', 'reshape', 'choose', 'repeat', 'put', 'putmask', +# functions that are now methods +__all__ = ['take', 'reshape', 'choose', 'repeat', 'put', 'putmask', 'swapaxes', 'transpose', 'sort', 'argsort', 'argmax', 'argmin', 'searchsorted', 'alen', 'resize', 'diagonal', 'trace', 'ravel', 'nonzero', 'shape', @@ -44,7 +43,7 @@ def _wrapit(obj, method, *args, **kwds): result = wrap(result) return result -def take(a, indices, axis=0): +def take(a, indices, axis=None): try: take = a.take except AttributeError: @@ -53,8 +52,8 @@ def take(a, indices, axis=0): # not deprecated --- copy if necessary, view otherwise def reshape(a, newshape, order='C'): - """Change the shape of a to newshape. Return a new view object if possible - otherwise return a copy. + """Change the shape of a to newshape. + Return a new view object if possible otherwise return a copy. """ try: reshape = a.reshape @@ -69,7 +68,7 @@ def choose(a, choices): return _wrapit(a, 'choose', choices) return choose(choices) -def repeat(a, repeats, axis=0): +def repeat(a, repeats, axis=None): """repeat elements of a repeats times along axis repeats is a sequence of length a.shape[axis] telling how many times to repeat each element. @@ -222,7 +221,6 @@ def trace(a, offset=0, axis1=0, axis2=1, dtype=None): """ return asarray(a).trace(offset, axis1, axis2, dtype) -# not deprecated --- always returns a 1-d array. Copy-if-necessary. def ravel(m,order='C'): """ravel(m) returns a 1d array corresponding to all the elements of it's argument. The new array is a view of m if possible, otherwise it is @@ -279,7 +277,7 @@ def clip(m, m_min, m_max): return _wrapit(m, 'clip', m_min, m_max) return clip(m_min, m_max) -def sum(x, axis=0, dtype=None): +def sum(x, axis=None, dtype=None): """Sum the array over the given axis. The optional dtype argument is the data type for intermediate calculations. @@ -308,7 +306,7 @@ def sum(x, axis=0, dtype=None): return _wrapit(x, 'sum', axis, dtype) return sum(axis, dtype) -def product (x, axis=0, dtype=None): +def product (x, axis=None, dtype=None): """Product of the array elements over the given axis.""" try: prod = x.prod @@ -316,7 +314,7 @@ def product (x, axis=0, dtype=None): return _wrapit(x, 'prod', axis, dtype) return prod(axis, dtype) -def sometrue (x, axis=0): +def sometrue (x, axis=None): """Perform a logical_or over the given axis.""" try: any = x.any @@ -324,7 +322,7 @@ def sometrue (x, axis=0): return _wrapit(x, 'any', axis) return any(axis) -def alltrue (x, axis=0): +def alltrue (x, axis=None): """Perform a logical_and over the given axis.""" try: all = x.all @@ -350,7 +348,7 @@ def all(x,axis=None): return _wrapit(x, 'all', axis) return all(axis) -def cumsum (x, axis=0, dtype=None): +def cumsum (x, axis=None, dtype=None): """Sum the array over the given axis.""" try: cumsum = x.cumsum @@ -358,7 +356,7 @@ def cumsum (x, axis=0, dtype=None): return _wrapit(x, 'cumsum', axis, dtype) return cumsum(axis, dtype) -def cumproduct (x, axis=0, dtype=None): +def cumproduct (x, axis=None, dtype=None): """Sum the array over the given axis.""" try: cumprod = x.cumprod @@ -366,7 +364,7 @@ def cumproduct (x, axis=0, dtype=None): return _wrapit(x, 'cumprod', axis, dtype) return cumprod(axis, dtype) -def ptp(a, axis=0): +def ptp(a, axis=None): """Return maximum - minimum along the the given dimension """ try: @@ -375,7 +373,7 @@ def ptp(a, axis=0): return _wrapit(a, 'ptp', axis) return ptp(axis) -def amax(a, axis=0): +def amax(a, axis=None): """Return the maximum of 'a' along dimension axis. """ try: @@ -384,7 +382,7 @@ def amax(a, axis=0): return _wrapit(a, 'max', axis) return max(axis) -def amin(a, axis=0): +def amin(a, axis=None): """Return the minimum of a along dimension axis. """ try: @@ -402,7 +400,7 @@ def alen(a): except TypeError: return len(array(a,ndmin=1)) -def prod(a, axis=0, dtype=None): +def prod(a, axis=None, dtype=None): """Return the product of the elements along the given axis """ try: @@ -411,7 +409,7 @@ def prod(a, axis=0, dtype=None): return _wrapit(a, 'prod', axis, dtype) return prod(axis, dtype) -def cumprod(a, axis=0, dtype=None): +def cumprod(a, axis=None, dtype=None): """Return the cumulative product of the elments along the given axis """ try: @@ -463,8 +461,8 @@ def round_(a, decimals=0): around = round_ -def mean(a, axis=0, dtype=None): - """mean(a, axis=0, dtype=None) +def mean(a, axis=None, dtype=None): + """mean(a, axis=None, dtype=None) Return the arithmetic mean. The mean is the sum of the elements divided by the number of elements. @@ -477,8 +475,8 @@ def mean(a, axis=0, dtype=None): return _wrapit(a, 'mean', axis, dtype) return mean(axis, dtype) -def std(a, axis=0, dtype=None): - """std(sample, axis=0, dtype=None) +def std(a, axis=None, dtype=None): + """std(sample, axis=None, dtype=None) Return the standard deviation, a measure of the spread of a distribution. The standard deviation is the square root of the average of the squared @@ -492,8 +490,8 @@ def std(a, axis=0, dtype=None): return _wrapit(a, 'std', axis, dtype) return std(axis, dtype) -def var(a, axis=0, dtype=None): - """var(sample, axis=0, dtype=None) +def var(a, axis=None, dtype=None): + """var(sample, axis=None, dtype=None) Return the variance, a measure of the spread of a distribution. The variance is the average of the squared deviations from the mean, diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py index 166a2d5cc..252ba70cd 100644 --- a/numpy/core/numeric.py +++ b/numpy/core/numeric.py @@ -323,7 +323,6 @@ set_string_function = multiarray.set_string_function set_string_function(array_str, 0) set_string_function(array_repr, 1) - little_endian = (sys.byteorder == 'little') def indices(dimensions, dtype=int): @@ -337,7 +336,7 @@ def indices(dimensions, dtype=int): return array(lst) def fromfunction(function, dimensions, **kwargs): - """fromfunction(function, dimensions) returns an array constructed by + """fromfunction(function, dimensions, dtype=int) returns an array constructed by calling function on a tuple of number grids. The function should accept as many arguments as there are dimensions which is a list of numbers indicating the length of the desired output for each axis. @@ -345,7 +344,8 @@ def fromfunction(function, dimensions, **kwargs): The function can also accept keyword arguments which will be passed in as well. """ - args = indices(dimensions) + dtype = kwargs.get('dtype', int) + args = indices(dimensions,dtype=dtype) return function(*args,**kwargs) def isscalar(num): diff --git a/numpy/lib/tests/test_function_base.py b/numpy/lib/tests/test_function_base.py index 4642725fc..9a1825e39 100644 --- a/numpy/lib/tests/test_function_base.py +++ b/numpy/lib/tests/test_function_base.py @@ -20,7 +20,7 @@ class test_any(NumpyTestCase): def check_nd(self): y1 = [[0,0,0],[0,1,0],[1,1,0]] assert(any(y1)) - assert_array_equal(sometrue(y1),[1,1,0]) + assert_array_equal(sometrue(y1,axis=0),[1,1,0]) assert_array_equal(sometrue(y1,axis=1),[0,1,1]) class test_all(NumpyTestCase): @@ -36,7 +36,7 @@ class test_all(NumpyTestCase): def check_nd(self): y1 = [[0,0,1],[0,1,1],[1,1,1]] assert(not all(y1)) - assert_array_equal(alltrue(y1),[0,0,1]) + assert_array_equal(alltrue(y1,axis=0),[0,0,1]) assert_array_equal(alltrue(y1,axis=1),[0,0,1]) class test_average(NumpyTestCase): diff --git a/numpy/oldnumeric/__init__.py b/numpy/oldnumeric/__init__.py index 439cfe907..67874f814 100644 --- a/numpy/oldnumeric/__init__.py +++ b/numpy/oldnumeric/__init__.py @@ -2,20 +2,32 @@ from numpy import * from compat import * from olddefaults import * +from typeconv import * +from functions import * import numpy import compat import olddefaults +import typeconv +import functions __version__ = numpy.__version__ __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) + +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 0a4b41228..3c8cf9b70 100644 --- a/numpy/oldnumeric/compat.py +++ b/numpy/oldnumeric/compat.py @@ -7,7 +7,7 @@ __all__ = ['NewAxis', 'UInt8','UInt16','UInt32', 'UnsignedInt32', 'UnsignedInteger', # UnsignedInt64 and Unsigned128 added below if possible # same for Int64 and Int128, Float128, and Complex128 - 'Int8', 'Int16', 'Int32', + 'Int8', 'Int16', 'Int32', 'Int0', 'Int', 'Float0', 'Float', 'Complex0', 'Complex', 'PyObject', 'Float32', 'Float64', 'Float16', 'Float8', 'Complex32', 'Complex64', 'Complex8', 'Complex16', @@ -19,6 +19,7 @@ __all__ = ['NewAxis', 'dump', 'dumps' ] + import numpy.core.multiarray as mu import numpy.core.umath as um import numpy.core.numerictypes as nt @@ -38,6 +39,7 @@ 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 |