Array Creation Routines#

From shape or value#

empty(shape[, dtype])

Return a new array of given shape and type, without initializing entries.

empty_like(prototype[, dtype, order, shape])

Return a new array with the same shape and type as a given array.

eye(N[, M, k, dtype])

Return a 2-D array with ones on the diagonal and zeros elsewhere.

identity(n[, dtype])

Return the identity array.

ones(shape[, dtype])

Return a new array of given shape and type, filled with ones.

ones_like(prototype[, dtype, order, shape])

Return an array of ones with the same shape and type as a given array.

zeros(shape[, dtype])

Return a new array of given shape and type, without initializing entries.

zeros_like(prototype[, dtype, order, shape])

Return an array of zeros with the same shape and type as a given array.

From existing data#

array(object[, dtype, copy, order, ndmin, subok])

Creates a BlockArray.

copy(a[, order, subok])

Return an array copy of the given object.

loadtxt(fname[, dtype, comments, delimiter, ...])

Load data from a text file.

Numerical ranges#

arange([start, stop, step, dtype])

Return evenly spaced values within a given interval.

linspace(start, stop[, num, endpoint, ...])

Return evenly spaced numbers over a specified interval.

logspace(start, stop[, num, endpoint, base, ...])

Return numbers spaced evenly on a log scale.

Building matrices#

diag(v[, k])

Extract a diagonal or construct a diagonal array.