pad¶
- array_api_extra.pad(x, pad_width, mode='constant', *, constant_values=0, xp=None)¶
Pad the input array.
- Parameters:
x (
object) – Input array.pad_width (
int|tuple[int,int] |Sequence[tuple[int,int]]) – 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.ndimcopies of this tuple.mode (
Literal['constant']) – Only “constant” mode is currently supported, which pads with the value passed to constant_values.constant_values (
complex) – Use this value to pad the input. Default is zero.xp (
ModuleType|None) – The standard-compatible namespace for x. Default: infer.
- Returns:
The input array, padded with
pad_widthelements equal toconstant_values.- Return type: