def ediff1d(arr, to_end=None, to_begin=None):
arr = ma.asanyarray(arr).flat<EOL>ed = arr[<NUM_LIT:1>:] - arr[:-<NUM_LIT:1>]<EOL>arrays = [ed]<EOL>if to_begin is not None:<EOL><INDENT>arrays.insert(<NUM_LIT:0>, to_begin)<EOL><DEDENT>if to_end is not None:<EOL><INDENT>arrays.append(to_end)<EOL><DEDENT>if len(arrays) != <NUM_LIT:1>:<EOL><INDENT>ed = hstack(arrays)<EOL><DEDENT>return ed<EOL>
Compute the differences between consecutive elements of an array.

This function is the equivalent of `numpy.ediff1d` that takes masked
values into account, see `numpy.ediff1d` for details.

See Also
--------
numpy.ediff1d : Equivalent function for ndarrays.