numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
identity(n, dtype=None, *, like=None)

The identity array is a square array with ones on the main diagonal.

Parameters

n : int

Number of rows (and columns) in n x n output.

dtype : data-type, optional

Data-type of the output. Defaults to float .

like : array_like

Reference object to allow the creation of arrays which are not NumPy arrays. If an array-like passed in as like supports the __array_function__ protocol, the result will be defined by it. In this case, it ensures the creation of an array object compatible with that passed in via this argument.

versionadded

Returns

out : ndarray

n x n array with its main diagonal set to one, and all other elements 0.

Return the identity array.

Examples

>>> np.identity(3)
array([[1.,  0.,  0.],
       [0.,  1.,  0.],
       [0.,  0.,  1.]])
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.eye scipy.signal._signaltools.order_filter

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/core/numeric.py#2131
type: <class 'function'>
Commit: