diff --git a/cunumeric/module.py b/cunumeric/module.py index c076200f8..e89396970 100644 --- a/cunumeric/module.py +++ b/cunumeric/module.py @@ -6255,6 +6255,7 @@ def diff( The first difference is given by ``out[i] = a[i+1] - a[i]`` along the given axis, higher differences are calculated by using `diff` recursively. + Parameters ---------- a : array_like @@ -6271,6 +6272,7 @@ def diff( arrays with length 1 in the direction of axis and the shape of the input array in along all other axes. Otherwise the dimension and shape must match `a` except along axis. + Returns ------- diff : ndarray @@ -6279,17 +6281,21 @@ def diff( type of the output is the same as the type of the difference between any two elements of `a`. This is the same as the type of `a` in most cases. + See Also -------- numpy.diff + Notes ----- Type is preserved for boolean arrays, so the result will contain - `False` when consecutive elements are the same and `True` when they + False when consecutive elements are the same and True when they differ. + For unsigned integer arrays, the results will also be unsigned. This should not be surprising, as the result is consistent with calculating the difference directly: + >>> u8_arr = np.array([1, 0], dtype=np.uint8) >>> np.diff(u8_arr) array([255], dtype=uint8) @@ -6300,8 +6306,10 @@ def diff( >>> i16_arr = u8_arr.astype(np.int16) >>> np.diff(i16_arr) array([-1], dtype=int16) + Examples -------- + >>> x = np.array([1, 2, 4, 7, 0]) >>> np.diff(x) array([ 1, 2, 3, -7]) diff --git a/docs/cunumeric/source/api/math.rst b/docs/cunumeric/source/api/math.rst index a4f71d1cf..4dd574dd7 100644 --- a/docs/cunumeric/source/api/math.rst +++ b/docs/cunumeric/source/api/math.rst @@ -55,6 +55,7 @@ Sums, products, differences .. autosummary:: :toctree: generated/ + diff prod sum cumprod diff --git a/docs/cunumeric/source/api/statistics.rst b/docs/cunumeric/source/api/statistics.rst index 48f10f19c..fe6ceb4bd 100644 --- a/docs/cunumeric/source/api/statistics.rst +++ b/docs/cunumeric/source/api/statistics.rst @@ -22,6 +22,7 @@ Histograms bincount histogram + digitize Order statistics