From 917b0794e8e68a443f94299a80c51491cdc1c6cb Mon Sep 17 00:00:00 2001 From: Eric Wieser Date: Mon, 25 Jun 2018 23:56:16 -0700 Subject: DOC: Clear up confusion between np.where(cond) and np.where(cond, x, y) Eliminates all mentions of `np.where(cond)`, instead pointing the reader to np.nonzero. Also changes some example numbers to avoid collisions, making them easier to follow. Some minor doc improvements for np.ma.where too. --- numpy/lib/arraysetops.py | 8 ++++++++ 1 file changed, 8 insertions(+) (limited to 'numpy/lib/arraysetops.py') diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index 4d3f35183..5880ea154 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -607,6 +607,14 @@ def isin(element, test_elements, assume_unique=False, invert=False): [ True, False]]) >>> element[mask] array([2, 4]) + + The indices of the matched values can be obtained with `nonzero`: + + >>> np.nonzero(mask) + (array([0, 1]), array([1, 0])) + + The test can also be inverted: + >>> mask = np.isin(element, test_elements, invert=True) >>> mask array([[ True, False], -- cgit v1.2.1