diff options
-rw-r--r-- | doc/source/reference/routines.indexing.rst | 8 | ||||
-rw-r--r-- | numpy/lib/index_tricks.py | 29 | ||||
-rw-r--r-- | numpy/lib/twodim_base.py | 20 |
3 files changed, 49 insertions, 8 deletions
diff --git a/doc/source/reference/routines.indexing.rst b/doc/source/reference/routines.indexing.rst index f618fa0a4..9d8fde882 100644 --- a/doc/source/reference/routines.indexing.rst +++ b/doc/source/reference/routines.indexing.rst @@ -21,6 +21,13 @@ Generating index arrays ix_ ogrid unravel_index + diag_indices + diag_indices_from + mask_indices + tril_indices + tril_indices_from + triu_indices + triu_indices_from Indexing-like operations ------------------------ @@ -42,6 +49,7 @@ Inserting data into arrays place put putmask + fill_diagonal Iterating over arrays --------------------- diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 3388decf0..cec7a7ac9 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -695,6 +695,14 @@ def fill_diagonal(a, val): Value to be written on the diagonal, its type must be compatible with that of the array a. + See also + -------- + diag_indices, diag_indices_from + + Notes + ----- + .. versionadded:: 1.4.0 + Examples -------- >>> a = zeros((3,3),int) @@ -722,10 +730,6 @@ def fill_diagonal(a, val): [0, 0, 0], [0, 0, 4]]) - See also - -------- - - diag_indices: indices to access diagonals given shape information. - - diag_indices_from: indices to access diagonals given an array. """ if a.ndim < 2: raise ValueError("array must be at least 2-d") @@ -761,6 +765,14 @@ def diag_indices(n, ndim=2): ndim : int, optional The number of dimensions. + Notes + ----- + .. versionadded:: 1.4.0 + + See also + -------- + diag_indices_from + Examples -------- Create a set of indices to access the diagonal of a (4,4) array: @@ -792,10 +804,6 @@ def diag_indices(n, ndim=2): [[0, 0], [0, 1]]]) - See also - -------- - - diag_indices_from: create the indices based on the shape of an existing - array. """ idx = arange(n) return (idx,) * ndim @@ -809,6 +817,11 @@ def diag_indices_from(arr): Parameters ---------- arr : array, at least 2-d + + Notes + ----- + .. versionadded:: 1.4.0 + """ if not arr.ndim >= 2: diff --git a/numpy/lib/twodim_base.py b/numpy/lib/twodim_base.py index 533408887..6c9eb5dbb 100644 --- a/numpy/lib/twodim_base.py +++ b/numpy/lib/twodim_base.py @@ -592,6 +592,10 @@ def mask_indices(n,mask_func,k=0): The indices corresponding to the locations where mask_func(ones((n,n)),k) is True. + Notes + ----- + .. versionadded:: 1.4.0 + Examples -------- These are the indices that would allow you to access the upper triangular @@ -633,6 +637,10 @@ def tril_indices(n,k=0): k : int, optional Diagonal offset (see tril() for details). + Notes + ----- + .. versionadded:: 1.4.0 + Examples -------- Commpute two different sets of indices to access 4x4 arrays, one for the @@ -691,6 +699,10 @@ def tril_indices_from(arr,k=0): k : int, optional Diagonal offset (see tril() for details). + Notes + ----- + .. versionadded:: 1.4.0 + """ if not arr.ndim==2 and arr.shape[0] == arr.shape[1]: raise ValueError("input array must be 2-d and square") @@ -708,6 +720,10 @@ def triu_indices(n,k=0): k : int, optional Diagonal offset (see triu() for details). + Notes + ----- + .. versionadded:: 1.4.0 + Examples -------- Commpute two different sets of indices to access 4x4 arrays, one for the @@ -766,6 +782,10 @@ def triu_indices_from(arr,k=0): k : int, optional Diagonal offset (see triu() for details). + Notes + ----- + .. versionadded:: 1.4.0 + """ if not arr.ndim==2 and arr.shape[0] == arr.shape[1]: raise ValueError("input array must be 2-d and square") |