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