larray.Array.reshape
- Array.reshape(target_axes) Array [source]
Given a list of new axes, changes the shape of the array. The size of the array (= number of elements) must be equal to the product of length of target axes.
- Parameters
- target_axesiterable of Axis
New axes. The size of the array (= number of stored data) must be equal to the product of length of target axes.
- Returns
- Array
New array with new axes but same data.
Examples
>>> arr = ndtest((2, 2, 2)) >>> arr a b\c c0 c1 a0 b0 0 1 a0 b1 2 3 a1 b0 4 5 a1 b1 6 7 >>> new_arr = arr.reshape([Axis('a=a0,a1'), ... Axis(['b0c0', 'b0c1', 'b1c0', 'b1c1'], 'bc')]) >>> new_arr a\bc b0c0 b0c1 b1c0 b1c1 a0 0 1 2 3 a1 4 5 6 7