ravel - flatten or combine dimensions of an array
arr.ravel()
arr.ravel(axis)
arr.ravel(ax0, ax1,
...)
The ravel() method flattens or combines
dimensions of the given arr. This is similar to APL ,
arr and
,[axis]arr.
If no argument is provided, the entire array is flattened into a single-dimensional array (vector).
If axis is an array or range of integers, the specified dimensions are combined into a single dimension. The specified axes must be contiguous.
If axis is a floating-point value, a new dimension of size
1 is inserted at the position specified by the integer portion of the
value. For example, 1.5 would insert a new
dimension between axis 1 and axis 2.
If axis is an integer, it is range-checked against the rank of the array, and then the entire array is flattened (similar to providing no argument).
A new array with the modified shape, sharing the same data as arr.
ArgCheck if the number of arguments is
incorrect
TypeCheck if axis is not
a supported type
RangeCheck if axis
is out of the valid range of dimensions
ShapeCheck if axis (as an array) does not
specify contiguous dimensions
a = [2,3,4].iterate()
a
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
a.ravel()
0 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23
a.ravel(0,1)
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
a.ravel([1,2])
0 1 2 3 4 5 6 7 8 9 10 11
12 13 14 15 16 17 18 19 20 21 22 23
a.ravel(0.5)
0 1 2 3
4 5 6 7
8 9 10 11
12 13 14 15
16 17 18 19
20 21 22 23
a.ravel(0.5).shape()
2 1 3 4