dask 2021.10.0

ParametersReturnsBackRef
diag(v)

This docstring was copied from numpy.diag.

Some inconsistencies with the Dask version may exist.

See the more detailed documentation for numpy.diagonal if you use this function to extract a diagonal and wish to write to the resulting array; whether it returns a copy or a view depends on what version of numpy you are using.

Parameters

v : array_like

If v is a 2-D array, return a copy of its k-th diagonal. If v is a 1-D array, return a 2-D array with v on the k-th diagonal.

k : int, optional (Not supported in Dask)

Diagonal in question. The default is 0. Use :None:None:`k>0` for diagonals above the main diagonal, and :None:None:`k<0` for diagonals below the main diagonal.

Returns

out : ndarray

The extracted diagonal or constructed diagonal array.

Extract a diagonal or construct a diagonal array.

See Also

diagflat

Create a 2-D array with the flattened input as a diagonal.

diagonal

Return specified diagonals.

trace

Sum along diagonals.

tril

Lower triangle of an array.

triu

Upper triangle of an array.

Examples

This example is valid syntax, but we were not able to check execution
>>> x = np.arange(9).reshape((3,3))  # doctest: +SKIP
... x # doctest: +SKIP array([[0, 1, 2], [3, 4, 5], [6, 7, 8]])
This example is valid syntax, but we were not able to check execution
>>> np.diag(x)  # doctest: +SKIP
array([0, 4, 8])
This example is valid syntax, but we were not able to check execution
>>> np.diag(x, k=1)  # doctest: +SKIP
array([1, 5])
This example is valid syntax, but we were not able to check execution
>>> np.diag(x, k=-1)  # doctest: +SKIP
array([3, 7])
This example is valid syntax, but we were not able to check execution
>>> np.diag(np.diag(x))  # doctest: +SKIP
array([[0, 0, 0],
       [0, 4, 0],
       [0, 0, 8]])
See :

Back References

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

dask.array.reductions.trace dask.array.routines.select dask.array.creation.diagonal dask.array.routines.compress

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


File: /dask/array/creation.py#569
type: <class 'function'>
Commit: