Array manipulation routines#

Basic operations#

ndim(a)

Return the number of dimensions of an array.

shape(a)

Return the shape of an array.

Changing array shape#

reshape(a, newshape[, order])

Gives a new shape to an array without changing its data.

ravel(a[, order])

Return a contiguous flattened array.

Transpose-like operations#

moveaxis(a, source, destination)

Move axes of an array to new positions.

swapaxes(a, axis1, axis2)

Interchange two axes of an array.

transpose(a[, axes])

Permute the dimensions of an array.

See also cunumeric.ndarray.T property.

Changing number of dimensions#

atleast_1d(*arys)

Convert inputs to arrays with at least one dimension.

atleast_2d(*arys)

View inputs as arrays with at least two dimensions.

atleast_3d(*arys)

View inputs as arrays with at least three dimensions.

broadcast_arrays(*args[, subok])

Broadcast any number of arrays against each other.

broadcast_shapes(*args)

Broadcast the input shapes into a single shape.

broadcast_to(arr, shape[, subok])

Broadcast an array to a new shape.

squeeze(a[, axis])

Remove single-dimensional entries from the shape of an array.

Changing kind of array#

asarray(a[, dtype])

Convert the input to an array.

Joining arrays#

append(arr, values[, axis])

Append values to the end of an array.

concatenate(inputs[, axis, out, dtype, casting])

concatenate((a1, a2, ...), axis=0, out=None, dtype=None, casting="same_kind")

stack(arrays[, axis, out])

Join a sequence of arrays along a new axis.

block(arrays)

Assemble an nd-array from nested lists of blocks.

vstack(tup)

Stack arrays in sequence vertically (row wise).

hstack(tup)

Stack arrays in sequence horizontally (column wise).

dstack(tup)

Stack arrays in sequence depth wise (along third axis).

column_stack(tup)

Stack 1-D arrays as columns into a 2-D array.

row_stack(tup)

Stack arrays in sequence vertically (row wise).

Splitting arrays#

split(a, indices[, axis])

Split an array into multiple sub-arrays as views into ary.

array_split(a, indices[, axis, equal])

Split an array into multiple sub-arrays.

dsplit(a, indices)

Split array into multiple sub-arrays along the 3rd axis (depth).

hsplit(a, indices)

Split an array into multiple sub-arrays horizontally (column-wise).

vsplit(a, indices)

Split an array into multiple sub-arrays vertically (row-wise).

Tiling arrays#

tile(A, reps)

Construct an array by repeating A the number of times given by reps.

Rearranging elements#

flip(m[, axis])

Reverse the order of elements in an array along the given axis.

fliplr(m)

Reverse the order of elements along axis 1 (left/right).

flipud(m)

Reverse the order of elements along axis 0 (up/down).