numpy 1.22.4 Pypi GitHub Homepage
Other Docs
ParametersReturnsBackRef
tri(N, M=None, k=0, dtype=<class 'float'>, *, like=None)

Parameters

N : int

Number of rows in the array.

M : int, optional

Number of columns in the array. By default, M is taken equal to N.

k : int, optional

The sub-diagonal at and below which the array is filled. k = 0 is the main diagonal, while k < 0 is below it, and k > 0 is above. The default is 0.

dtype : dtype, optional

Data type of the returned array. The default is 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

tri : ndarray of shape (N, M)

Array with its lower triangle filled with ones and zero elsewhere; in other words T[i,j] == 1 for j <= i + k , 0 otherwise.

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

Examples

>>> np.tri(3, 5, 2, dtype=int)
array([[1, 1, 1, 0, 0],
       [1, 1, 1, 1, 0],
       [1, 1, 1, 1, 1]])
>>> np.tri(3, 5, -1)
array([[0.,  0.,  0.,  0.,  0.],
       [1.,  0.,  0.,  0.,  0.],
       [1.,  1.,  0.,  0.,  0.]])
See :

Back References

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

skimage.transform.finite_radon_transform.frt2 dask.array.creation.tri skimage.transform.finite_radon_transform.ifrt2

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/lib/twodim_base.py#370
type: <class 'function'>
Commit: