Skip to main content

reshape

Change the shape of an array without changing its data. Returns a view if the array is C-contiguous, otherwise returns a copy. Use -1 for one dimension to have its size inferred automatically.
Returns: NDArray — Array with the specified shape. View when possible, copy otherwise.

flatten

Return a 1-D copy of the array. Unlike ravel, flatten always allocates new memory.
Returns: NDArray — A 1-D array containing all elements in row-major (C) order. Always a copy.

ravel

Return a contiguous flattened 1-D array. Returns a view if the array is already C-contiguous, otherwise returns a copy (same data as flatten in that case).
Returns: NDArray — A 1-D array. View when the input is C-contiguous, copy otherwise.

squeeze

Remove axes of length 1 from the array shape. Returns a view (no data is copied).
Returns: NDArray — View of a with the specified length-1 dimensions removed.

expand_dims

Insert a new axis (dimension of length 1) at the given position. Returns a view.
Returns: NDArray — View of a with an additional dimension inserted.

resize

Return a new array with the given shape. If the new size is larger, the data is repeated (cycled). If smaller, the data is truncated. Always returns a new array (not a view).
Returns: NDArray — New array with the specified shape, filled by repeating or truncating elements from a.