diff options
author | Pauli Virtanen <pav@iki.fi> | 2009-03-24 22:25:21 +0000 |
---|---|---|
committer | Pauli Virtanen <pav@iki.fi> | 2009-03-24 22:25:21 +0000 |
commit | 7b751f66c7feb71646f0c2540aca2e5e67cd5db5 (patch) | |
tree | 3c33eab7a5933af7300ee4949c541511ebb7f915 /numpy/lib/arraysetops.py | |
parent | 940a7d3b4e6398a742873347a2f3c605ceffe481 (diff) | |
download | numpy-7b751f66c7feb71646f0c2540aca2e5e67cd5db5.tar.gz |
Merge from the doc wiki
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r-- | numpy/lib/arraysetops.py | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py index f023f6027..9afb00f29 100644 --- a/numpy/lib/arraysetops.py +++ b/numpy/lib/arraysetops.py @@ -52,17 +52,16 @@ def ediff1d(ary, to_end=None, to_begin=None): If provided, this number will be taked onto the beginning of the returned differences. - Notes - ----- - When applied to masked arrays, this function drops the mask information - if the `to_begin` and/or `to_end` parameters are used - - Returns ------- ed : array The differences. Loosely, this will be (ary[1:] - ary[:-1]). + Notes + ----- + When applied to masked arrays, this function drops the mask information + if the `to_begin` and/or `to_end` parameters are used + """ ary = np.asanyarray(ary).flat ed = ary[1:] - ary[:-1] @@ -285,11 +284,22 @@ def setmember1d(ar1, ar2): mask : ndarray, bool The values `ar1[mask]` are in `ar2`. + See Also -------- numpy.lib.arraysetops : Module with a number of other functions for performing set operations on arrays. + Examples + -------- + >>> test = np.arange(5) + >>> states = [0, 2] + >>> mask = np.setmember1d(test,states) + >>> mask + array([ True, False, True, False, False], dtype=bool) + >>> test[mask] + array([0, 2]) + """ ar1 = np.asarray( ar1 ) ar2 = np.asarray( ar2 ) |