Pad an array. Parameters ---------- array : array_like of rank N The array to pad. pad_width : {sequence, array_like, int} Number of values padded to the edges of each axis. ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths for
(array, pad_width, mode='constant', **kwargs)
| 532 | |
| 533 | @array_function_dispatch(_pad_dispatcher, module='numpy') |
| 534 | def pad(array, pad_width, mode='constant', **kwargs): |
| 535 | """ |
| 536 | Pad an array. |
| 537 | |
| 538 | Parameters |
| 539 | ---------- |
| 540 | array : array_like of rank N |
| 541 | The array to pad. |
| 542 | pad_width : {sequence, array_like, int} |
| 543 | Number of values padded to the edges of each axis. |
| 544 | ``((before_1, after_1), ... (before_N, after_N))`` unique pad widths |
| 545 | for each axis. |
| 546 | ``(before, after)`` or ``((before, after),)`` yields same before |
| 547 | and after pad for each axis. |
| 548 | ``(pad,)`` or ``int`` is a shortcut for before = after = pad width |
| 549 | for all axes. |
| 550 | mode : str or function, optional |
| 551 | One of the following string values or a user supplied function. |
| 552 | |
| 553 | 'constant' (default) |
| 554 | Pads with a constant value. |
| 555 | 'edge' |
| 556 | Pads with the edge values of array. |
| 557 | 'linear_ramp' |
| 558 | Pads with the linear ramp between end_value and the |
| 559 | array edge value. |
| 560 | 'maximum' |
| 561 | Pads with the maximum value of all or part of the |
| 562 | vector along each axis. |
| 563 | 'mean' |
| 564 | Pads with the mean value of all or part of the |
| 565 | vector along each axis. |
| 566 | 'median' |
| 567 | Pads with the median value of all or part of the |
| 568 | vector along each axis. |
| 569 | 'minimum' |
| 570 | Pads with the minimum value of all or part of the |
| 571 | vector along each axis. |
| 572 | 'reflect' |
| 573 | Pads with the reflection of the vector mirrored on |
| 574 | the first and last values of the vector along each |
| 575 | axis. |
| 576 | 'symmetric' |
| 577 | Pads with the reflection of the vector mirrored |
| 578 | along the edge of the array. |
| 579 | 'wrap' |
| 580 | Pads with the wrap of the vector along the axis. |
| 581 | The first values are used to pad the end and the |
| 582 | end values are used to pad the beginning. |
| 583 | 'empty' |
| 584 | Pads with undefined values. |
| 585 | |
| 586 | .. versionadded:: 1.17 |
| 587 | |
| 588 | <function> |
| 589 | Padding function, see Notes. |
| 590 | stat_length : sequence or int, optional |
| 591 | Used in 'maximum', 'mean', 'median', and 'minimum'. Number of |
nothing calls this directly
no test coverage detected