diff options
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r-- | numpy/lib/index_tricks.py | 19 |
1 files changed, 16 insertions, 3 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index f573cd4c6..84c161b2e 100644 --- a/numpy/lib/index_tricks.py +++ b/numpy/lib/index_tricks.py @@ -41,6 +41,10 @@ def ix_(*args): Parameters ---------- args : 1-D sequences + Each sequence should be of integer or boolean type. + Boolean sequences will be interpreted as boolean masks for the + corresponding dimension (equivalent to passing in + ``np.nonzero(boolean_sequence)``). Returns ------- @@ -58,7 +62,7 @@ def ix_(*args): >>> a array([[0, 1, 2, 3, 4], [5, 6, 7, 8, 9]]) - >>> ixgrid = np.ix_([0,1], [2,4]) + >>> ixgrid = np.ix_([0, 1], [2, 4]) >>> ixgrid (array([[0], [1]]), array([[2, 4]])) @@ -68,6 +72,15 @@ def ix_(*args): array([[2, 4], [7, 9]]) + >>> ixgrid = np.ix_([True, True], [2, 4]) + >>> a[ixgrid] + array([[2, 4], + [7, 9]]) + >>> ixgrid = np.ix_([True, True], [False, False, True, False, True]) + >>> a[ixgrid] + array([[2, 4], + [7, 9]]) + """ out = [] nd = len(args) @@ -658,8 +671,8 @@ s_ = IndexExpression(maketuple=False) def fill_diagonal(a, val, wrap=False): """Fill the main diagonal of the given array of any dimensionality. - For an array `a` with ``a.ndim > 2``, the diagonal is the list of - locations with indices ``a[i, i, ..., i]`` all identical. This function + For an array `a` with ``a.ndim >= 2``, the diagonal is the list of + locations with indices ``a[i, ..., i]`` all identical. This function modifies the input array in-place, it does not return a value. Parameters |