mindspore.numpy.ediff1d

mindspore.numpy.ediff1d(ary, to_end=None, to_begin=None)[源代码]

The differences between consecutive elements of a tensor.

参数
  • ary (Tensor) – If necessary, will be flattened before the differences are taken.

  • to_end (Tensor or scalar, optional) – Number(s) to append at the end of the returned differences.

  • to_begin (Tensor or scalar, optional) – Number(s) to prepend at the beginning of the returned differences.

返回

The differences.

异常

TypeError – If inputs have types not specified above.

Supported Platforms:

Ascend GPU CPU

样例

>>> import mindspore.numpy as np
>>> arr = np.array([1, 3, -1, 0, 4])
>>> print(np.ediff1d(arr))
[ 2 -4  1  4]