diff options
author | Eric Wieser <wieser.eric@gmail.com> | 2017-02-19 11:36:24 +0000 |
---|---|---|
committer | GitHub <noreply@github.com> | 2017-02-19 11:36:24 +0000 |
commit | aba10bb5829caee63a20251a226d8cb716ec1125 (patch) | |
tree | fe3d440500115959cd2ad080939f114dcc9cc142 /numpy/lib/index_tricks.py | |
parent | 4f8ccdf83cb447a35a410d8904f3299f5a384b9c (diff) | |
parent | 8d31fcb09b1a704bfa2b692bc322847cfae52132 (diff) | |
download | numpy-aba10bb5829caee63a20251a226d8cb716ec1125.tar.gz |
Merge pull request #8633 from MSeifert04/boolean_arrays_in_ix__func
DOC: Mention boolean arrays in the ix_ documentation.
Diffstat (limited to 'numpy/lib/index_tricks.py')
-rw-r--r-- | numpy/lib/index_tricks.py | 15 |
1 files changed, 14 insertions, 1 deletions
diff --git a/numpy/lib/index_tricks.py b/numpy/lib/index_tricks.py index 7f9419e9b..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) |