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])

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(a[, dtype, 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, filled with zeros.

zeros_like(a[, dtype, shape])

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

full(shape, value[, dtype])

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

full_like(a, value[, dtype, shape])

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

From existing data#

array(object[, dtype, copy])

Create an array.

asarray(a[, dtype])

Convert the input to an array.

copy(a)

Return an array copy of the given object.

repeat(a, repeats[, axis])

Repeat elements of an array.

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.

Building matrices#

diag(v[, k])

Extract a diagonal or construct a diagonal array.

tri(N[, M, k, dtype, like])

An array with ones at and below the given diagonal and zeros elsewhere.

tril(m[, k])

Lower triangle of an array.

triu(m[, k])

Upper triangle of an array.