summaryrefslogtreecommitdiff
path: root/numpy/core/numeric.py
diff options
context:
space:
mode:
authorTravis Oliphant <oliphant@enthought.com>2006-09-28 09:56:41 +0000
committerTravis Oliphant <oliphant@enthought.com>2006-09-28 09:56:41 +0000
commit7906451af30f3c29250937863b22199cf9f42dfd (patch)
tree53463f5e33fb7b7c87b7f6b892c4c280fe36d181 /numpy/core/numeric.py
parent483ce064ed954b8b9235f69f06bbbcff35d5fe4d (diff)
downloadnumpy-7906451af30f3c29250937863b22199cf9f42dfd.tar.gz
Fix the fromfunction routine to use float as default. Update oldnumeric and numarray compatibility modules.
Diffstat (limited to 'numpy/core/numeric.py')
-rw-r--r--numpy/core/numeric.py24
1 files changed, 14 insertions, 10 deletions
diff --git a/numpy/core/numeric.py b/numpy/core/numeric.py
index eb476eb3e..63cb264b1 100644
--- a/numpy/core/numeric.py
+++ b/numpy/core/numeric.py
@@ -448,17 +448,21 @@ def indices(dimensions, dtype=int):
lst.append( add.accumulate(tmp, i, dtype)-1 )
return array(lst)
-def fromfunction(function, dimensions, **kwargs):
- """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.
-
- The function can also accept keyword arguments which will be
- passed in as well.
+def fromfunction(function, shape, **kwargs):
+ """returns an array constructed by calling a function on a tuple
+ of number grids. The function should accept as many arguments as the
+ length of shape and work on array inputs. The shape argument is a
+ sequence of numbers indicating the length of the desired output
+ for each axis.
+
+ The function can also accept keyword arguments (except dtype),
+ which will be passed through fromfunction to the function itself.
+ The dtype argument (default float) determines the data-type of
+ the index grid passed to the function.
+
"""
- dtype = kwargs.get('dtype', int)
- args = indices(dimensions,dtype=dtype)
+ dtype = kwargs.pop('dtype', float)
+ args = indices(shape, dtype=dtype)
return function(*args,**kwargs)
def isscalar(num):