summaryrefslogtreecommitdiff
path: root/numpy/lib/arraysetops.py
diff options
context:
space:
mode:
authorPauli Virtanen <pav@iki.fi>2009-10-02 19:27:46 +0000
committerPauli Virtanen <pav@iki.fi>2009-10-02 19:27:46 +0000
commit1521f6689a3cc48d60a75097a7ffcf4d51f9dc47 (patch)
treea0f048838717b7ee43177007ec42c3102ea7be25 /numpy/lib/arraysetops.py
parent8c7d1bc554e6b5bbb7900a2f6d976d72795bb454 (diff)
downloadnumpy-1521f6689a3cc48d60a75097a7ffcf4d51f9dc47.tar.gz
Docstring updates, part 1
Diffstat (limited to 'numpy/lib/arraysetops.py')
-rw-r--r--numpy/lib/arraysetops.py39
1 files changed, 28 insertions, 11 deletions
diff --git a/numpy/lib/arraysetops.py b/numpy/lib/arraysetops.py
index b8ae9a9f3..89f82a942 100644
--- a/numpy/lib/arraysetops.py
+++ b/numpy/lib/arraysetops.py
@@ -40,24 +40,41 @@ def ediff1d(ary, to_end=None, to_begin=None):
Parameters
----------
- ary : array
- This array will be flattened before the difference is taken.
- to_end : number, optional
- If provided, this number will be tacked onto the end of the returned
- differences.
- to_begin : number, optional
- If provided, this number will be tacked onto the beginning of the
- returned differences.
+ ary : array_like
+ If necessary, will be flattened before the differences are taken.
+ to_end : array_like, optional
+ Number(s) to append at the end of the returned differences.
+ to_begin : array_like, optional
+ Number(s) to prepend at the beginning of the returned differences.
Returns
-------
- ed : array
- The differences. Loosely, this will be (ary[1:] - ary[:-1]).
+ ed : ndarray
+ The differences. Loosely, this is ``ary.flat[1:] - ary.flat[:-1]``.
+
+ See Also
+ --------
+ diff, gradient
Notes
-----
When applied to masked arrays, this function drops the mask information
- if the `to_begin` and/or `to_end` parameters are used
+ if the `to_begin` and/or `to_end` parameters are used.
+
+ Examples
+ --------
+ >>> x = np.array([1, 2, 4, 7, 0])
+ >>> np.ediff1d(x)
+ array([ 1, 2, 3, -7])
+
+ >>> np.ediff1d(x, to_begin=-99, to_end=np.array([88, 99]))
+ array([-99, 1, 2, 3, -7, 88, 99])
+
+ The returned array is always 1D.
+
+ >>> y = [[1, 2, 4], [1, 6, 24]]
+ >>> np.ediff1d(y)
+ array([ 1, 2, -3, 5, 18])
"""
ary = np.asanyarray(ary).flat