Shape functions

Force a sequence of arrays (including array scalars) to each be at least 1-d.

Force a sequence of arrays (including array scalars) to each be at least 2-d. Dimensions of length 1 are pre-pended to reach a two-dimensional array.

Force a sequence of arrays (including array .scalars) to each be at least 3-d. Dimensions of length 1 are pre-pended to reach a two-dimensional array.

roll (arr, shift, axis=None)

Return a new array with the contents of arr shifted (rolled) by the amount given in the integer argument shift along the axis specified. If axis is None, then the shift takes place in the ravelled array (but the returned array has the same shape as arr). Elements that shift outside the array are rolled back into the array from the opposite side.

rollaxis (arr, axis, start)

Return arr transposed so that the provided axis is inserted into the shape before start with the other dimensions rolled. Thus, if arr.shape is (i,j,k,l) then rollaxis(arr, 2, 0) has shape (k,i,j,l) and rollaxis(arr, 1, 3) has shape (i,k,j,l).

vstack (seq)

Stack a sequence of arrays along the first axis (row wise). Arrays in seq must have the same shape along all dimensions but the first. Rebuilds array divided by vsplit. All 1-d arrays will be stacked row-wise.

hstack (seq)

Stack a sequence of arrays along the second axis (column wise). Arrays in seq must have the same shape along all dimensions but the second. Rebuilds array divided by hsplit. Notice that 1-d arrays will be appended into a new

1-d array. Use column_stack to get a 2-d array from 1-d arrays. If some arrays are already 2-d, then the 1-d arrays need to have a dimension added to the end (e.g. y[:, newaxis] ) in order to stack correctly.

column_stack (seq)

Stack a sequence of arrays as columns into a 2-d array. 1-d arrays are converted to

2-d arrays and transposed. All arrays must have shapes so that the resulting array is well defined. Compare with hstack.

row_stack (seq)

Stack a sequence of 1-d arrays as rows into a 2-d array (alias for vstack).

dstack (seq)

Stack a sequence of arrays along the third axis (depth wise). Arrays in seq must have the same shape along all dimensions but the third. Rebuilds array divided by vsplit.

Divide ary into a list of sub-arrays along the specified axis. The i_orj3 argument stands for indices_or.sections. If i_or_s is an integer, ary is divided into that many equally-sized arrays. If it is impossible to make an even split, each of the leading arrays in the returned list have one additional member. If i_orj3 is a list of sorted integer, its entries define the indexes where ary is split. An empty list for i_or_s results in a single sub-array equal to the original array.

The same as array_split() except if i_or_s is an integer and it is impossible to make an even split, an error is raised.

Split a single array into multiple columns of sub-arrays (along the first axis if 1-d or along the second second if >1-d). Only works on arrays of 1 or more dimension.

+1 0

Post a comment