numpy.ma.fromfunction(function,shape,**kwargs) = <numpy.ma.core._convert2ma object>¶Construct an array by executing a function over each coordinate.
The resulting array therefore has a valuefn(x,y,z) atcoordinate(x,y,z).
| Parameters: |
|
|---|---|
| Returns: |
|
See also
indices,meshgrid
Notes
Keywords other thandtype are passed tofunction.
Examples
>>>np.fromfunction(lambdai,j:i==j,(3,3),dtype=int)array([[ True, False, False], [False, True, False], [False, False, True]])
>>>np.fromfunction(lambdai,j:i+j,(3,3),dtype=int)array([[0, 1, 2], [1, 2, 3], [2, 3, 4]])