| |
- findgen(shape)
- Create a Float32 array of shape filled with 1-D indices.
Output is a single-precision floating point Numeric array with
shape given by argument shape, where the elements of the array
are filled with the values of the 1-D indices that would be
given in a Numeric.ravel()ed version of the array. This function
is similar in purpose to the IDL FINDGEN function.
Positional Input Argument:
* shape: If is 1-D tuple of integers, argument specifies the
shape of the output array. If argument shape is a scalar, the
output array is a 1-D vector with argument shape number of
elements.
Examples:
>>> from findgen import findgen
>>> array = findgen(5)
>>> ['%.1f' % array[i] for i in range(len(array))]
['0.0', '1.0', '2.0', '3.0', '4.0']
>>> array.shape
(5,)
>>> array.typecode()
'f'
>>> array = findgen((3,4))
>>> ['%.1f' % array[0,i] for i in range(4)]
['0.0', '1.0', '2.0', '3.0']
>>> ['%.1f' % array[1,i] for i in range(4)]
['4.0', '5.0', '6.0', '7.0']
>>> ['%.1f' % array[2,i] for i in range(4)]
['8.0', '9.0', '10.0', '11.0']
>>> array.shape
(3, 4)
|