array_api_extra.pad¶
- array_api_extra.pad(x, pad_width, mode='constant', *, constant_values=0, xp=None)¶
Pad the input array.
- Parameters:
x (array) – Input array.
pad_width (int or tuple of ints or sequence of pairs of ints) – Pad the input array with this many elements from each side. If a sequence of tuples,
[(before_0, after_0), ... (before_N, after_N)]
, each pair applies to the corresponding axis ofx
. A single tuple,(before, after)
, is equivalent to a list ofx.ndim
copies of this tuple.mode (str, optional) – Only “constant” mode is currently supported, which pads with the value passed to constant_values.
constant_values (python scalar, optional) – Use this value to pad the input. Default is zero.
xp (array_namespace, optional) – The standard-compatible namespace for x. Default: infer.
- Returns:
The input array, padded with
pad_width
elements equal toconstant_values
.- Return type:
array